Skip to content

Commit 601f0bc

Browse files
committed
#505 Solved
1 parent 7de892f commit 601f0bc

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

numeral.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,16 @@
396396

397397
// Multiply up by precision, round accurately, then divide and use native toFixed():
398398
output = (roundingFunction(value + 'e+' + boundedPrecision) / power).toFixed(boundedPrecision);
399+
if (Number(output) > value){
400+
if (output.includes('.')) {
401+
l = output.split('.')[1].length;
402+
new_num = 10 **(-l);
403+
new2_num = Number(output) - new_num;
404+
output = new2_num.toString();
405+
}
406+
output = (roundingFunction(output + 'e+' + boundedPrecision) / power).toFixed(boundedPrecision);
399407

408+
}
400409
if (optionals > maxDecimals - boundedPrecision) {
401410
optionalsRegExp = new RegExp('\\.?0{1,' + (optionals - (maxDecimals - boundedPrecision)) + '}$');
402411
output = output.replace(optionalsRegExp, '');

0 commit comments

Comments
 (0)