Giter Club home page Giter Club logo

stringmath's Introduction

StringMath.js

A javascript library that calculate the big number(Even greater than 2^53);

parameter and return

Allow input number or string(we can call it StringNumber, number represented by a string, RegExp: /^+-\w+$/), it should be noted that the maximum number of JS security is Math.pow(2, 53) - 1, function all return string(StringNumber);

Use

plus (+)

Allow at least one parameter;

StringMath.plus(-Math.pow(2, 50), '-3234324823992349023439204', 343242.34, Math.pow(4, 23));

subtract (-)

Allow at least one parameter;

StringMath.subtract(Math.pow(2, 43), '34237489741142345487987745646784', -45415.323);

multiply (*)

Allow at least one parameter;

StringMath.multiply(Math.pow(2, 53)-1, '789749712323434', -87977.23434454);

divide (/)

Allow at least one parameter;

StringMath.DIVIDE_DECIMAL_LIMIT(default 5) to set decimal length; StringMath._divide_remain to keep the last devide remain data; StringMath._divide_int_result to keep the last devide int result;

StringMath.divide(343432432423, '123645648797456787448978797', -4545.771231);

mod (%)

Allow two parameters;

StringMath.mod('789749712323434', -4545.32);

eq (=)

Allow two parameters;

StringMath.eq('789749712323434', 789749712323434);

gt (>)

Allow two parameters;

StringMath.gt(1, '12345673234');

gte (>=)

Allow two parameters;

StringMath.gte(1, '12345673234');

lt (<)

Allow two parameters;

StringMath.lt('2137489127897541278789', 53);

lte (<=)

Allow two parameters;

StringMath.lt('2137489127897541278789', '2137489127897541278789');

max

get the maximum number of the inputs Allow at least two parameters;

StringMath.max(1, '2137489127897541278789', Math.pow(2, 32));

min

get the minimum number of the inputs Allow at least two parameters;

StringMath.min(1, '2137489127897541278789', Math.pow(2, 32));

round

Allow only one parameter;

StringMath.round('2137489127897541278789.3243434324');

ceil

Allow only one parameter;

StringMath.ceil('-2137489127897541278789.3243434324');

floor

Allow only one parameter;

StringMath.floor('2137489127897541278789.3243434324');

abs

Allow only one parameter;

StringMath.abs('-2137489127897541278789.3243434324');

toFixed

Allow two parameters, first is StringNumber, second is the decimal length youd want to keep;

StringMath.toFixed('2137489127897541278789.324567', 4); // => '2137489127897541278789.3246'

pow

Allow two parameters, first is StringNumber, second is the exponent sign(do not support decimal number);

StringMath.pow('2137489127897541278789.332', '3323');

system

Convert the decimal StringNumber to other system, like Number.prototype.toString(radix) Allow two parameters, first is StringNumber, second is the target system to convert (less than 36);

StringMath.system('2137489127897541278789', 36);

bin

decimal to binary Allow one parameter, it is the StringNumber;

StringMath.bin('2137489127897541278789');

oct

decimal to octonary Allow one parameter, it is the StringNumber;

StringMath.oct('2137489127897541278789');

hex

decimal to hexadecimal Allow one parameter, it is the StringNumber;

StringMath.hex('2137489127897541278789');

dec

Convert the other system StringNumber to decimal system, like parseFloat(Number, radix) Allow two parameters, first is StringNumber, second is the origin system (less than 36);

StringMath.dec('2137489127897541278789', 36);

stringmath's People

Contributors

replace5 avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

dglyoo

stringmath's Issues

roadmap

Hi, I like this project,
Most I like its functional style compared to BigNumber.js, and this library is much smaller.

It would be interesting to me, if we could make it an NPM module.
I would also like to add some tests to increase the trust in this module.

I found this project, because recently our database administrator changed some field in mysql from int to long. In first place it was ok to handle the field as string, but I have to compute those values.

can you give me some thoughts, where you want to go with this project?

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.