feross / feross/buffer

Writing NaN differs from nodejs Buffer

Open
#197 5 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
1.9k
Forks
260
PR merge metrics
No merged PRs in 30d

Description

Hello,

I was recently attempting to swap out nodejs' Buffer with this one on a fork of another project, so I could use it in a non-node environment, when I noticed an inconsistency between nodejs' Buffer and this library when dealing with `NaN`

Here's a sample (using most recent npm install of 'buffer'):
```
const AltBuffer = require('buffer/').Buffer;

const alt_buf = new AltBuffer(8);
const node_buf = new Buffer(8);

alt_buf.writeDoubleLE(NaN, 0);
node_buf.writeDoubleLE(NaN, 0);

```
in node 6.x, 8.x, and 9.x, the resulting buffer objects are different

Node's (native) Buffer:
`00 00 00 00 00 00 f8 7f`

buffer library's Buffer:
`01 00 00 00 00 00 f0 7f` - bytes 0 and 6 are different

That's probably not supposed to happen, right?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.