-
-
Notifications
You must be signed in to change notification settings - Fork 234
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
Buffer treats decimal numbers mod 100?? #317
Comments
That's a |
That's approximately what parseInt does, which is fine. The problem seems to be from Buffer, not parseInt:
some other array with |
The maximum value of a byte is 255. Buffer is a Uint8Array (rather than a Uint8ClampedArray), so values get wrapped.
|
Yes. Although it oddly wraps at 100 instead of 256. I think Buffer is treating the result of parseInt as 0x100 instead of 100. I don't know the exact interface between Buffer and parseInt; perhaps this is difficult to fix and best remain a "feature" rather than a bug. It is unintuitive but perhaps it's just how Buffers work and there's no way around it. |
A hexadecimal
There's no bug here. |
Running v17.3.0,
Buffer.from("abcde")
returns<Buffer 61 62 63 64 65>
as expectedBuffer.from("abcde").map(x=>parseInt(x,16))
returns<Buffer 97 98 99 00 01>
This is probably not the intended behavior of
Buffer
The text was updated successfully, but these errors were encountered: