🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

fraction-math-js

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fraction-math-js - npm Package Compare versions

Comparing version
0.1.6
to
0.1.7
+8
-12
index.js

@@ -9,2 +9,7 @@ "use strict"

}
const reduction=function(n,d){//reduction of a fraction
let g=gcd(n,d);
return [n.dividedBy(g),d.dividedBy(g)];
}
const nsign=(n,d)=>(d.isNegative())?[n.times(-1),d.abs()]:[n,d];//set negative sign
class Opt{

@@ -70,3 +75,3 @@ constructor(opt){

if (v.isInt()&&d.isInt())
return [toBN(v),toBN(d)];
return reduction(...nsign(v,d));
let toF=(n)=>new F(...toFrac(n));

@@ -119,8 +124,3 @@ return toF(v).dividedBy(toF(d));

let n=nx.plus(ny);
let g2=gcd(n,d);
if (d.isNegative()) {
d=d.abs();
n=n.times(-1);
}
let r=[n.dividedBy(g2),d.dividedBy(g2)];
let r=reduction(...nsign(n,d));
return r;

@@ -140,7 +140,3 @@ }

let n=x.n.dividedBy(g2).times(y.n.dividedBy(g1));
if (d.isNegative()) {
d=d.abs();
n=n.times(-1);
}
let r=[n,d];
let r=nsign(n,d);
return r;

@@ -147,0 +143,0 @@ }

+1
-1
{
"name": "fraction-math-js",
"version": "0.1.6",
"version": "0.1.7",
"description": "",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -8,2 +8,3 @@ "use strict"

assert.ok(new Frac("1.1","1.1").toString()==="1","1.1 , 1.1 = 1");//decimal 1.1/1.1=1
assert.ok(new Frac("2",-6).toString()==="-1/3","2 , -6 = -1/3");//decimal 2,-6 = -1/3
assert.ok(new Frac("1 1 1 + +").toString()==="3","1 1 1 + + = 3");//Postfix 1 1 1 + + = 1 2 + = 3

@@ -21,2 +22,3 @@ assert.ok(new Frac("- * 3 2 1").toString()==="5","- * 3 2 1 = 5");//Prefix - * 3 2 1 = - 6 1 = 5

m[0]=555;
assert.ok(x.toString()==="123","not constant");
assert.ok(x.toString()==="123","not constant");
assert.ok(new Frac("0.99999999999999999999999999999999999999999999999999999999999999999999999999999999").toString()==="99999999999999999999999999999999999999999999999999999999999999999999999999999999/100000000000000000000000000000000000000000000000000000000000000000000000000000000","0.99999999999999999999999999999999999999999999999999999999999999999999999999999999 = 99999999999999999999999999999999999999999999999999999999999999999999999999999999/100000000000000000000000000000000000000000000000000000000000000000000000000000000");