Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Bug with toFixed() method

I think I've found a bug with the Number.prototype.toFixed() method. It can be reproduced in Fitbit Studio by starting a new project with the Minimal template, and putting this in app/index.js:

 

let fixed = Number(0.1).toFixed(3)
console.log(`${fixed} <-- expected 0.100 here `)

What actually gets logged to the console is:

 

0.1

 

Note that there are two abnormalities here:

  1. The toFixed() method should return '0.100'
  2. The rest of the string ('<-- expected 0.100 here')in the console.log call is not printed.
Best Answer
2 REPLIES 2

Looks like the fix for this missed the release! It should be included in the next update! Thanks for raising this.

Best Answer

I can confirm that this bug is still there in latest version (27.32.10.20) of Ionic. However, the bug is not present in Fitbit OS Simulator.

 

Testing on Ionic

index.js

console.log("91:" + parseFloat(91).toFixed(1));
console.log("91.0:" + parseFloat(91.0).toFixed(1)); console.log("91.5:" + parseFloat(91.5).toFixed(1)); console.log("'91':" + parseFloat("91").toFixed(1)); console.log("'91.0':" + parseFloat("91.0").toFixed(1)); console.log("'91.5':" + parseFloat("91.5").toFixed(1));

Console

91: 91.
91.0: 91.
91.5: 91.0
'91': 91.
'91.0': 91.
'91.5': 91.0

Testing on Fitbit OS Simulator

Console

91: 91.0
91.0: 91.0
91.5: 91.5
'91': 91.0
'91.0': 91.0
'91.5': 91.5
Best Answer
0 Votes