Socket
Socket
Sign inDemoInstall

baser

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    baser

Free basing at its finest.


Version published
Maintainers
1
Install size
43.3 kB
Created

Readme

Source

baser

Convert numbers from a javascript base10 number to other bases. Can either run in "pure" mode (which runs into issues with mantissa and divisibility) or "accurate" mode which is certain to always keep the digits the same when going back to original base but does not give you the right numbers to use in mathematical operations.

Why the two modes? Often we are using this library to compress quite long numbers where we don't want to lose precision after the decimal. Accurate is much more useful, as we don't have to worry about loss of data when converting back to base 10.

Currently this only works in "accurate" mode for research sake.

Example

Start by installing the package:

npm install baser

Then initialize the object and start using it.

var libBaser = require('baser');

var baser = libBaser.new();

var integerconversion = baser.convert(100200300);
console.log('Converting the integer 100200300 to a base 62 number: '+integerconversion);

var decimalconversion = baser.convert(1.100200300);
console.log('Converting 1.100200300 to a base 62 number: '+decimalconversion);

Which will output the following to the command-line:

Converting the integer 100200300 to a base 62 number: 6mQfs
Converting 1.100200300 to a base 62 number: 1.4CfL

Keywords

FAQs

Last updated on 05 Dec 2016

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc