round off decimal using javascript

(Math.round((16.185*Math.pow(10,2)).toFixed(1))/Math.pow(10,2)).toFixed(2); If your value is, for example 16.199 normal round will return 16.2… but with this method youll get last 0 too, so you see 16.20! But keep in mind that the value will returned as string. If you want to use it for further operations, you have to parsefloat it 🙂 And now as … Read more

Double vs Decimal Rounding in C#

Why 1/3 as a double is 0.33333333333333331 The closest way to represent 1/3 in binary is like this: 0.0101010101… That’s the same as the series 1/4 + (1/4)^2 + (1/4)^3 + (1/4)^4… Of course, this is limited by the number of bits you can store in a double. A double is 64 bits, but one … Read more