int2buf

0.2.0 • Public • Published

#int2buf

Convert an unsigned double to a 64 bit integer represented as a buffer.

Installation

npm install int2buf

Documentation

There is only one function int2buf. It takes a number and returns a buffer. If the number is negative or above or equal to 18446744073709552000 the module throws an RangeError. Note that once you above 52bit you start lossing precision, this is because JavaScript uses double types for all numbers.

The buffer have its least significant bit stored last (big endian).

var int2buf = require('int2buf');

console.log(int2buf(Math.pow(2, 33) - 1)); // <Buffer 00 00 00 01 ff ff ff ff>

##License

The software is license under "MIT"

Copyright (c) 2014 Andreas Madsen

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package Sidebar

Install

npm i int2buf

Weekly Downloads

1

Version

0.2.0

License

MIT

Last publish

Collaborators

  • andreasmadsen