Skip to content

Commit

Permalink
Merge pull request #39 from Vaultio/denomination_changes
Browse files Browse the repository at this point in the history
Adding a new conversion function to Denomination
  • Loading branch information
pr0zac authored Sep 21, 2018
2 parents 9478b54 + 4289da5 commit 152d565
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 152d565

Please sign in to comment.