Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readFloat64xx doesn't work properly #2

Open
w35l3y opened this issue May 22, 2012 · 0 comments
Open

readFloat64xx doesn't work properly #2

w35l3y opened this issue May 22, 2012 · 0 comments

Comments

@w35l3y
Copy link
Contributor

w35l3y commented May 22, 2012

Both functions readFloat64BE and readFloat64LE are buggy at the following line:

(((b5 & 0x7F) << 24) | (b6 << 16) | (b7 << 8) | b8).toString(2)

If you do, for example:
var b5 = 0, b6 = 0, b7 = 0, b8 = 0;

The expected value should be "0000000000000000000000000000000" (31 zeros), but instead it returns "0"

I solved it by using:

("000000000000000000000000000000" + (((b5 & 0x7F) << 24) | (b6 << 16) | (b7 << 8) | b8).toString(2)).substr(-31)

But this solution isn't cross-browser.

Tested on Firefox 12.0

Thank you for your great work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant