Skip to content

Commit

Permalink
readability tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
simontreanor committed Feb 21, 2024
1 parent 7526ec1 commit 2a38669
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Currency.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ module Currency =
module Cent =
/// max of two cent values
let max (c1: int64<Cent>) (c2: int64<Cent>) = max (int64 c1) (int64 c2) * 1L<Cent>

/// min of two cent values
let min (c1: int64<Cent>) (c2: int64<Cent>) = min (int64 c1) (int64 c2) * 1L<Cent>

/// derive a rounded cent value from a decimal according to the specified rounding method
let round rounding (m: decimal) =
match rounding with
Expand All @@ -25,7 +27,9 @@ module Currency =
| Round mpr -> Math.Round(m, 0, mpr)
|> int64
|> (( * ) 1L<Cent>)

/// lower to the base currency unit
let fromDecimal (m: decimal) = round (Round MidpointRounding.AwayFromZero) (m * 100m)

/// raise to the standard currency unit
let toDecimal (c: int64<Cent>) = decimal c / 100m

0 comments on commit 2a38669

Please sign in to comment.