J
John G Harris
<snip>******
The OP asked about rounding a number to 2 decimals - not about converting it
to a string.
***
The most reliable way to do decimal rounding is to operate on the
decimal representation of the number. In javascript this means you have
to start by translating the internal binary representation into a
string. (At present. Microsoft wanted numbers to be decimal-coded. I
don't know if they still do.)
This is probably what JohnS meant. Then again, perhaps not. It's not
always easy to work out what he means when he's operating in sarcastic
teacher mode.
Actually, the OP didn't say if he wants decimal rounding, or hexadecimal
rounding, or duodecimal rounding, or ternary rounding, or binary
rounding to two places. We are all guessing he meant decimal as that's
what most people want to display to their end users.
John