Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
I want to ask, how to store a number (integer in JS) in buffer using buffer.writeInt16BE().
Assume I have a number such as
var a = 40000;
40000(10) = 9C40 (16)
how can I store 40000 in buffer of size of 2, so it looks something like:
<9c, 40>
You can't use buf.writeInt16BE() because 40000 is larger than 32768. However if you use buf.writeUInt16BE() you can write 40000 to the buffer just fine.
buf.writeInt16BE()
buf.writeUInt16BE()
Add a comment
writeUInt16BE is not defined
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.