Coder Social home page Coder Social logo

bigbit / bigbitjs Goto Github PK

View Code? Open in Web Editor NEW
4.0 2.0 1.0 2.12 MB

Node js implementation of BigBit standard with online convertion and comparision tool

Home Page: https://bigbit.github.io/bigbitjs/

License: MIT License

HTML 23.79% JavaScript 76.21%
ieee754 bigbit bignumber binary32 binary64 floating-point float double utf-8 utf

bigbitjs's Introduction

BigBit

An improved data type to save large numbers in less space without precision loss. check more detail here. Or try the demo

var HBSequence = require('bigbit').HeaderByte;

let hb = new HBSequence('167770021700.00');
expect( hb.toString() ).toEqual('167770021700');
expect( hb.toByteArray() ).toEqual([69, 2, 121, 172, 255, 99]);
expect( HBSequence.decode( hb.toByteArray() ).toString() ).toEqual('167770021700'); //decode( byteArray, index[, maxNumberOfBytes ]);
expect( hb.exponent ).toEqual( 2 );
expect( hb.exponentInBytes ).toEqual( 2 );
expect( hb.headByte ).toEqual(69);

var EHBSequence = require('bigbit').ExtendedHeaderByte;

let ehb = new EHBSequence('167770021700.00');
expect( ehb.toString() ).toEqual('167770021700');
expect( ehb.toByteArray() ).toEqual([69, 2, 121, 172, 255, 99]);
expect( EHBSequence.decode( hb.toByteArray() ).toString() ).toEqual('167770021700.00'); //decode( byteArray, index[, maxNumberOfBytes ]);
expect( ehb.exponent ).toEqual( 2 );
expect( ehb.exponentInBytes ).toEqual( [2] );
expect( ehb.headByte ).toEqual(69);

var LBSequence = require('bigbit').LinkedBytes;
expect( LBSequence.encode('123000')  ).toEqual( [ 248, 192, 7]);
expect( LBSequence.decode([ 248, 192, 7])  ).toEqual({ val: '123000', len: 3});  //decode( byteArray, index[, maxNumberOfBytes ]);

bigbitjs's People

Contributors

amitguptagwl avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bigbitjs's Issues

Arithmetic operations not implemented in terms of BigBit formats themselves

Currently, the only way to perform arithmetic operations on BigBit numbers to convert them to BigNumbers, add these and encode them back to the original BigBit format. As the reference implementation, this strongly needs an implementation of BigBit arithmetics without BigNumbers, since such a type is not even present in certain languages, namely Rust, which I'm porting this format to (I'm trying to keep the crate as a zero-dependency self-sustaining implementation, thus using any other format as a helper construct simply hurts the proof of concept).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.