Skip to main content
5 events
when toggle format what by license comment
Aug 22, 2023 at 20:48 vote accept Sébastien Josserand
Aug 21, 2023 at 23:16 comment added J_H Good. Feel free to post new code in an answer, or perhaps request a new review. Just "do not change the code in the question after receiving an answer." // I wholeheartedly agree with changing to a "string in / string out" API. Consider .3 - .2 --> .0999...998. The trouble with the current API is it is unclear what number means. It has a precise mathematical meaning, which you don't like and want to adjust via rounding. Scaled integer or string would make more sense.
Aug 21, 2023 at 21:55 comment added Sébastien Josserand Thanks for your valuable answer. As you may noticed, it looks more like a personal function, it need improvements. The 2 returns give a parseFloat and may return NaN for a string input, and fatal error for null/undefined input (Math.round seems to return NaN in place of fatal error, I may make an update) I don't know for the epsilon, we may want to add or remove it depending on the calculation. round(4) before a round(2) may be interesting too Where should I update my new version? I should directly update the question? I'm not sure there's a better solution than working with string
Aug 21, 2023 at 21:27 history edited J_H CC BY-SA 4.0
retract "use FP arithmetic" remarks
Aug 21, 2023 at 21:06 history answered J_H CC BY-SA 4.0