Skip to content

Commit

Permalink
Adding a new conversion function to Denomination
Browse files Browse the repository at this point in the history
  • Loading branch information
pr0zac committed Sep 21, 2018
1 parent 9478b54 commit 4289da5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions EtherKit/Models/Denomination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,11 @@ public enum Denomination: BigUInt {
let (quotient, remainder) = value.value.quotientAndRemainder(dividingBy: denomination.rawValue)
return Double(quotient) + Double(remainder) / Double(denomination.rawValue)
}

public static func convert(
_ value: Double,
from denomination: Denomination
) -> UInt256 {
return UInt256(BigUInt(value * Double(denomination.rawValue)))
}
}

0 comments on commit 4289da5

Please sign in to comment.