fraction.js
Advanced tools
Comparing version 4.0.9 to 4.0.10
{ | ||
"name": "fraction.js", | ||
"main": "fraction.js", | ||
"version": "4.0.9", | ||
"version": "4.0.10", | ||
"homepage": "http://www.xarg.org/2014/03/rational-numbers-in-javascript/", | ||
@@ -6,0 +6,0 @@ "description": "A rational number library", |
/** | ||
* @license Fraction.js v4.0.9 09/09/2015 | ||
* @license Fraction.js v4.0.10 09/09/2015 | ||
* http://www.xarg.org/2014/03/rational-numbers-in-javascript/ | ||
@@ -622,7 +622,7 @@ * | ||
}, | ||
"simplify": function(eps) { | ||
// First naive implementation, needs improvement | ||
if (isNaN(this['n']) || isNaN(this['d'])) { | ||
@@ -633,5 +633,5 @@ return this; | ||
var cont = this['abs']()['toContinued'](); | ||
eps = eps || 0.001; | ||
function rec(a) { | ||
@@ -642,3 +642,3 @@ if (a.length === 1) | ||
} | ||
for (var i = 0; i < cont.length; i++) { | ||
@@ -784,3 +784,3 @@ var tmp = rec(cont.slice(0, i + 1)); | ||
dec = dec || 15; // 15 = decimal places when no repitation | ||
dec = dec || 15; // 15 = decimal places when no repitation | ||
@@ -787,0 +787,0 @@ var cycLen = cycleLen(N, D); // Cycle length |
/* | ||
Fraction.js v4.0.9 09/09/2015 | ||
Fraction.js v4.0.10 09/09/2015 | ||
http://www.xarg.org/2014/03/rational-numbers-in-javascript/ | ||
@@ -18,2 +18,2 @@ | ||
10*h%d,2E3<m){d=0;break a}d=m}}a:{h=1;m=10;for(var l=d,n=1;0<l;m=m*m%c,l>>=1)l&1&&(n=n*m%c);m=n;for(l=0;300>l;l++){if(h===m){m=l;break a}h=10*h%c;m=10*m%c}m=0}h=-1===this.s?"-":"";h+=b/c|0;(b=b%c*10)&&(h+=".");if(d){for(a=m;a--;)h+=b/c|0,b%=c,b*=10;h+="(";for(a=d;a--;)h+=b/c|0,b%=c,b*=10;h+=")"}else for(a=a||15;b&&a--;)h+=b/c|0,b%=c,b*=10;return h}};"function"===typeof define&&define.amd?define([],function(){return e}):"object"===typeof exports?(Object.defineProperty(exports,"__esModule",{value:!0}), | ||
e["default"]=e,e.Fraction=e,module.exports=e):x.Fraction=e})(this); | ||
e["default"]=e,e.Fraction=e,module.exports=e):x.Fraction=e})(this); |
{ | ||
"name": "fraction.js", | ||
"title": "fraction.js", | ||
"version": "4.0.9", | ||
"version": "4.0.10", | ||
"homepage": "http://www.xarg.org/2014/03/rational-numbers-in-javascript/", | ||
@@ -6,0 +6,0 @@ "bugs": "https://github.com/infusion/Fraction.js/issues", |
@@ -375,5 +375,5 @@ # Fraction.js - ℚ in JavaSript | ||
String toString([significantPlaces=15]) | ||
String toString([decimalPlaces=15]) | ||
--- | ||
Generates an exact string representation of the actual object. For repeated decimal places all digits are collected within brackets, like `1/3 = "0.(3)"`. For all other numbers, up to `decimalPlaces` significant digits are collected - which includes trailing zeros if the number is getting truncated. `1/2 = "0.5" of course. | ||
Generates an exact string representation of the actual object. For repeated decimal places all digits are collected within brackets, like `1/3 = "0.(3)"`. For all other numbers, up to `decimalPlaces` significant digits are collected - which includes trailing zeros if the number is getting truncated. However, `1/2 = "0.5"` without trailing zeros of course. | ||
@@ -380,0 +380,0 @@ **Note:** As `valueOf()` and `toString()` are provided, `toString()` is only called implicitly in a real string context. Using the plus-operator like `"123" + new Fraction` will call valueOf(), because JavaScript tries to combine two primitives first and concatenates them later, as string will be the more dominant type. `alert(new Fraction)` or `String(new Fraction)` on the other hand will do what you expect. If you really want to have control, you should call `toString()` or `valueOf()` explicitly! |
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
SPDX disjunction
LicenseSPDX disjunction for an artifact's license information
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
80365
13
1
2413