How do I round a JavaScript number to 2 decimal places?

Well that probably tells you everything you need to know about my school performance :rofl:

Interestingly, even 64bit Excel won't accept 1511000000005.2148, it will only take 2dp no matter what you do. 5.2148 is, of course fine. And yes, it rounds the shorter number to 5.21 as you expect.

Even more interesting in Excel. If you take the text of '1511000000005.2148' and use the formula =NUMBERVALUE("1511000000005.2148")-1511000000005, you get an answer of 0.2099609375

Which is, I think, a useful reminder that large numbers don't always do what you expect when working with computers.

OK, OK, yes I've now completely side-tracked my Saturday afternoon!! But using Excel's PowerQuery tools, you do get slightly more accurate results with such a large number. The same calculation as above gives an answer of 0.21484375.

Right, back to your normal content :sunglasses:

1 Like

I bet you were one of those kids where they said - "Could do better if he just tried" on the report card !!

And look how he has now blossomed !

Craig

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.