Packing floating point in NodeJS under 32 bit produces incorrect results - why?
-
I am using the following "pack" function provided by the excellent php.js project. http://github.com/kvz/phpjs/blob/master/functions/misc/pack.js Running this in Mozilla's JavaScript shell it works fine, but running it in Node produces incorrect strings. example, packing the number 2 as a Double with: pack('d',2); JS Shell produces: 00 00 00 00 00 00 00 40 (This is correct, PHP produces the same, and it is reversible) NodeJS produces: 00 00 00 00 00 00 10 00 (This is incorrect) Note all tests run on the same machine (CentOS 5 32 bit) Have I built NodeJS wrongly?
-
Answer:
There are a number of pack/unpack libraries available for node. Have you tried any of the others? I'd also suggest opening an issue on the author's github issue tracker.
Matt Ranney at Quora Visit the source
Other answers
Reinstalling with latest version Node v0.1.101 has improved matters, it is coping with integers, but is still failing on floating points
Tim Whitlock
Related Q & A:
- Why does Mathematica give an incorrect answer to this multiple integral?Best solution by Mathematica
- Why are the times on my email messages incorrect?Best solution by support.microsoft.com
- Will a Dazzle work with a 32 bit vista?Best solution by polygon89.wordpress.com
- What is the meaning of "dual core CPU" and "32 -bit operating system?Best solution by Yahoo! Answers
- Do I have a 32 bit or a 64 bit CPU?Best solution by computerhope.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.