f
This commit is contained in:
@@ -3,14 +3,14 @@ export function safeTruncate(num, decimals = 2) {
|
||||
return '0.00'
|
||||
|
||||
const factor = 10 ** decimals
|
||||
const scaled = Math.trunc(num * factor)
|
||||
const scaled = Math.round(num * factor)
|
||||
return (scaled / factor).toFixed(decimals)
|
||||
}
|
||||
|
||||
function toTruncatedCents(num) {
|
||||
if (Number.isNaN(num) || !Number.isFinite(num))
|
||||
return 0
|
||||
return Math.trunc((num + Number.EPSILON) * 100)
|
||||
return Math.round(num * 100)
|
||||
}
|
||||
|
||||
function centsToFixed(cents) {
|
||||
|
||||
Reference in New Issue
Block a user