File tree Expand file tree Collapse file tree 2 files changed +2
-1
lines changed Expand file tree Collapse file tree 2 files changed +2
-1
lines changed Original file line number Diff line number Diff line change @@ -7,4 +7,5 @@ test("fixed", async () => {
7
7
assert ( Fixed . fromDecimalString ( "0.1" , 2 ) . value === 10n )
8
8
assert ( Fixed . fromDecimalString ( ".1" , 2 ) . value === 10n )
9
9
assert ( Fixed . fromDecimalString ( "." , 2 ) . value === 0n )
10
+ assert ( Fixed . fromDecimalString ( "0" , 2 ) . value === 0n )
10
11
} )
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ export class Fixed<D extends number = number> {
78
78
}
79
79
80
80
static fromDecimalString < D extends number > ( text : string , decimals : D ) {
81
- const [ whole , decimal ] = text . split ( "." )
81
+ const [ whole = "0" , decimal = "0" ] = text . split ( "." )
82
82
const value = BigInt ( whole + decimal . padEnd ( decimals , "0" ) . slice ( 0 , decimals ) )
83
83
return new Fixed ( value , decimals )
84
84
}
You can’t perform that action at this time.
0 commit comments