@vsadx/true-binary

1.1.2 • Public • Published

Export machine binary from number

import { Binary } from "@vsadx/true-binary"

const some_num = 13

// `toString(2)` gives us the binary version of 13
some_num.toString(2) 

// this isn't how JavaScript sees numbers though, 
// it uses IEEE-754 floating point standard

// give it a try! 
Binary.stringify(13)

You can learn a lot about why some mathmatical operations are fast but other, even similar ones, are slower. In some cases, using the IEEE 754 format directly increased operation speeds for game developers at one time. This raw binary format lets you make speed vs accuracy tradeoffs more explicitly.

There are two methods so far; you can use stringify or parse. It is similar to the JSON object which also has those methods. In this case, there is no reviver parameter or much other configuration settings.

stringify(number: number, add_spaces: bool)

parse(stringified_binary: string)

Package Sidebar

Install

npm i @vsadx/true-binary

Weekly Downloads

0

Version

1.1.2

License

ISC

Unpacked Size

2.37 kB

Total Files

3

Last publish

Collaborators

  • vsadx