Is it possible to somehow emulate single precision float in Javascript? According to Doug Crockford's blog "Number is 64-bit floating point", but I have to use single one for porting C++ algorithm which calculates single precision float's error.
A:
Let me get this straight. You want to compute single precision float's mistake on a platform that has no single precision float. The trivial answer is that you can't.
The reason is you don't have the tools to accomplish such task. You've got toFixed
and toPrecision
methods as part of the Number
object, but they are working with digits not bits. Actually you also have Bitwise Operators, but they convert your number to int32
first.
galambalazs
2010-10-31 11:35:30