Skip to content

Commit

Permalink
make BigDecimal.scale dual
Browse files Browse the repository at this point in the history
  • Loading branch information
fubhy authored and mikearnaldi committed Oct 1, 2024
1 parent 9131e6d commit 89bc646
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/effect/src/BigDecimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,10 @@ export const normalize = (self: BigDecimal): BigDecimal => {
* @since 2.0.0
* @category scaling
*/
export const scale = (self: BigDecimal, scale: number): BigDecimal => {
export const scale: {
(scale: number): (self: BigDecimal) => BigDecimal
(self: BigDecimal, scale: number): BigDecimal
} = dual(2, (self: BigDecimal, scale: number): BigDecimal => {
if (scale > self.scale) {
return make(self.value * bigint10 ** BigInt(scale - self.scale), scale)
}
Expand All @@ -193,7 +196,7 @@ export const scale = (self: BigDecimal, scale: number): BigDecimal => {
}

return self
}
})

/**
* Provides an addition operation on `BigDecimal`s.
Expand Down

0 comments on commit 89bc646

Please sign in to comment.