bignumber.js
Advanced tools
Comparing version 1.0.1 to 1.1.0
@@ -1,2 +0,2 @@ | ||
/* bignumber.js v1.0.1 https://github.com/MikeMcl/bignumber.js/LICENCE */ | ||
/* bignumber.js v1.1.0 https://github.com/MikeMcl/bignumber.js/LICENCE */ | ||
;(function ( global ) { | ||
@@ -6,4 +6,4 @@ 'use strict'; | ||
/* | ||
bignumber.js v1.0.1 | ||
A Javascript library for arbitrary-precision arithmetic. | ||
bignumber.js v1.1.0 | ||
A JavaScript library for arbitrary-precision arithmetic. | ||
https://github.com/MikeMcl/bignumber.js | ||
@@ -80,3 +80,3 @@ Copyright (c) 2012 Michael Mclaughlin <M8ch88l@gmail.com> | ||
id = 0, | ||
isValid = /^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i, | ||
isValid = /^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i, | ||
trim = String.prototype.trim || function () {return this.replace(/^\s+|\s+$/g, '')}, | ||
@@ -97,3 +97,3 @@ ONE = BigNumber(1); | ||
function BigNumber( n, b ) { | ||
var isNum, i, j, | ||
var e, i, isNum, digits, valid, | ||
x = this; | ||
@@ -110,5 +110,5 @@ | ||
// i is undefined. | ||
if ( b !== i) { | ||
n = n['toS']() | ||
// e is undefined. | ||
if ( b !== e ) { | ||
n += '' | ||
} else { | ||
@@ -122,9 +122,10 @@ x['s'] = n['s']; | ||
// Check if number and if minus zero. Convert to string. | ||
// If number, check if minus zero. | ||
if ( typeof n != 'string' ) { | ||
n = ( isNum = Object.prototype.toString.call(n) == '[object Number]' ) && | ||
n === 0 && 1 / n < 0 ? '-0' : n + '' | ||
n = ( isNum = typeof n == 'number' || | ||
Object.prototype.toString.call(n) == '[object Number]' ) && | ||
n === 0 && 1 / n < 0 ? '-0' : n + '' | ||
} | ||
if ( b === i && isValid.test(n) ) { | ||
if ( b === e && isValid.test(n) ) { | ||
@@ -140,10 +141,7 @@ // Determine sign. | ||
if ( b == 10 ) { | ||
return new BigNumber(n)['div'](ONE) | ||
return setMode( n, DECIMAL_PLACES, ROUNDING_MODE ) | ||
} | ||
/* | ||
* Follow Javascript numbers in allowing numbers with fraction digits | ||
* to omit a leading zero and allowing a leading plus sign e.g. '+.5' for '0.5'. | ||
*/ | ||
n = trim.call(n).replace( /^\+(?!-)/, '' ).replace( /^(-?)\./, '$10.' ); | ||
n = trim.call(n).replace( /^\+(?!-)/, '' ); | ||
@@ -157,11 +155,16 @@ x['s'] = n.charAt(0) == '-' ? ( n = n.replace( /^-(?!-)/, '' ), -1 ) : 1; | ||
i = '[' + DIGITS.slice( 0, b = b | 0 ) + ']+'; | ||
digits = '[' + DIGITS.slice( 0, b = b | 0 ) + ']+'; | ||
// Test non-decimal number validity. | ||
// Before non-decimal number validity test and base conversion | ||
// remove the `.` from e.g. '1.', and replace e.g. '.1' with '0.1'. | ||
n = n.replace( /\.$/, '' ).replace( /^\./, '0.' ); | ||
// Any number in exponential form will fail due to the e+/-. | ||
if ( j = new RegExp( '^' + i + '(?:\\.' + i + ')?$', 'i' ).test(n) ) { | ||
if ( valid = new RegExp( | ||
'^' + digits + '(?:\\.' + digits + ')?$', 'i' ).test(n) ) { | ||
if ( isNum ) { | ||
if ( n.replace('.', '').length > 15 ) { | ||
if ( n.replace( '.', '' ).length > 15 ) { | ||
// 'new BigNumber() number type has more than 15 significant digits: {n}' | ||
@@ -175,2 +178,3 @@ ifExceptionsThrow( n, 0 ) | ||
n = convert( n, 10, b, x['s'] ) | ||
} else if ( n != 'Infinity' && n != 'NaN' ) { | ||
@@ -189,9 +193,9 @@ | ||
// Ignore base. | ||
j = isValid.test(n) | ||
valid = isValid.test(n) | ||
} | ||
} else { | ||
j = isValid.test(n) | ||
valid = isValid.test(n) | ||
} | ||
if ( !j ) { | ||
if ( !valid ) { | ||
@@ -219,3 +223,3 @@ // Infinity/NaN | ||
// Decimal point? | ||
if ( ( i = n.indexOf('.') ) > -1 ) { | ||
if ( ( e = n.indexOf('.') ) > -1 ) { | ||
n = n.replace( '.', '' ) | ||
@@ -225,15 +229,15 @@ } | ||
// Exponential form? | ||
if ( ( j = n.search(/e/i) ) > 0 ) { | ||
if ( ( i = n.search(/e/i) ) > 0 ) { | ||
// Determine exponent. | ||
if ( i < 0 ) { | ||
i = j | ||
if ( e < 0 ) { | ||
e = i | ||
} | ||
i += +n.slice( j + 1 ); | ||
n = n.substring( 0, j ) | ||
e += +n.slice( i + 1 ); | ||
n = n.substring( 0, i ) | ||
} else if ( i < 0 ) { | ||
} else if ( e < 0 ) { | ||
// Integer. | ||
i = n.length | ||
e = n.length | ||
} | ||
@@ -249,7 +253,7 @@ | ||
// Determine leading zeros. | ||
for ( id = j = 0; n.charAt(j) == '0'; j++ ) { | ||
for ( i = id = 0; n.charAt(i) == '0'; i++ ) { | ||
} | ||
// Overflow? | ||
if ( ( i -= j + 1 ) > MAX_EXP ) { | ||
if ( ( e -= i + 1 ) > MAX_EXP ) { | ||
@@ -260,3 +264,3 @@ // Infinity. | ||
// Zero or underflow? | ||
} else if ( j == b || i < MIN_EXP ) { | ||
} else if ( i == b || e < MIN_EXP ) { | ||
@@ -271,7 +275,7 @@ // Zero. | ||
x['e'] = i; | ||
x['e'] = e; | ||
x['c'] = []; | ||
// Convert string to array of digits (without leading and trailing zeros). | ||
for ( i = 0; j <= b; x['c'][i++] = +n.charAt(j++) ) { | ||
for ( e = 0; i <= b; x['c'][e++] = +n.charAt(i++) ) { | ||
} | ||
@@ -528,3 +532,2 @@ } | ||
fracBN = divide( dvd, dvs, dvd.length - dvs.length, sign, baseOut, | ||
// Is least significant digit of integer part an odd number? | ||
@@ -648,3 +651,3 @@ nArr[nArr.length - 1] & 1 ); | ||
// Leading zero? Do not remove if result is simply zero (qi == 1). | ||
if ( !qc[0] && qi != 1) { | ||
if ( !qc[0] && qi != 1 ) { | ||
@@ -729,3 +732,3 @@ // There can't be more than one zero. | ||
// Called by divide, format, setMode and sqrt. | ||
function rnd( x, dp, base, isOdd, r) { | ||
function rnd( x, dp, base, isOdd, r ) { | ||
var xc = x['c'], | ||
@@ -1419,3 +1422,3 @@ isNeg = x['s'] < 0, | ||
* rounded to a maximum of dp decimal places using rounding mode rm, or to | ||
* DECIMAL_PLACES and ROUNDING_MODE respectively if omitted. | ||
* 0 and ROUNDING_MODE respectively if omitted. | ||
* | ||
@@ -1647,3 +1650,3 @@ * [dp] {number} Integer, 0 to MAX inclusive. | ||
* | ||
* Note: as with Javascript's number type, (-0).toFixed(0) is '0', | ||
* Note: as with JavaScript's number type, (-0).toFixed(0) is '0', | ||
* but e.g. (-0.00001).toFixed(0) is '-0'. | ||
@@ -1869,3 +1872,3 @@ * | ||
if ( !( outOfRange = !( b >= 2 && b <= 36) ) && | ||
if ( !( outOfRange = !( b >= 2 && b <= 36 ) ) && | ||
( b == (b | 0) || !ERRORS ) ) { | ||
@@ -1875,3 +1878,3 @@ str = convert( str, b | 0, 10, x['s'] ); | ||
// Avoid '-0' | ||
if ( str == '0') { | ||
if ( str == '0' ) { | ||
return str | ||
@@ -1878,0 +1881,0 @@ } |
@@ -1,1 +0,1 @@ | ||
/* bignumber.js v1.0.1 https://github.com/MikeMcl/bignumber.js/LICENCE */(function(e){"use strict";function y(e,t){var n,r,i,s=this;if(!(s instanceof y))return new y(e,t);if(e instanceof y){d=0;if(t===r){s.s=e.s,s.e=e.e,s.c=(e=e.c)?e.slice():e;return}e=e.toS()}typeof e!="string"&&(e=(n=Object.prototype.toString.call(e)=="[object Number]")&&e===0&&1/e<0?"-0":e+"");if(t===r&&v.test(e))s.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1;else{if(t==10)return(new y(e)).div(g);e=m.call(e).replace(/^\+(?!-)/,"").replace(/^(-?)\./,"$10."),s.s=e.charAt(0)=="-"?(e=e.replace(/^-(?!-)/,""),-1):1,t!=null?t!=(t|0)&&!!f||(p=!(t>=2&&t<=36))?(b(t,2),i=v.test(e)):(r="["+h.slice(0,t|=0)+"]+",(i=(new RegExp("^"+r+"(?:\\."+r+")?$","i")).test(e))?(n&&(e.replace(".","").length>15&&b(e,0),n=!n),e=w(e,10,t,s.s)):e!="Infinity"&&e!="NaN"&&(b(e,1,t),e="NaN")):i=v.test(e);if(!i){s.c=s.e=null,e!="Infinity"&&(e!="NaN"&&b(e,3),s.s=null),d=0;return}}(r=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(r<0&&(r=i),r+=+e.slice(i+1),e=e.substring(0,i)):r<0&&(r=e.length),(t=e.length,n&&t>15)&&b(e,0);for(d=i=0;e.charAt(i)=="0";i++);if((r-=i+1)>a)s.c=s.e=null;else if(i==t||r<u)s.c=[s.e=0];else{for(;e.charAt(--t)=="0";);s.e=r,s.c=[];for(r=0;i<=t;s.c[r++]=+e.charAt(i++));}}function b(e,t,n,r,i,s){if(f){var o=["new BigNumber","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFr"][d?d<0?-d:d:1/d<0?1:0]+"()",u=p?" out of range":" not a"+(i?" non-zero":"n")+" integer";throw u=([o+" number type has more than 15 significant digits",o+" not a base "+n+" number",o+" base"+u,o+" not a number"][t]||n+"() "+t+(s?" not a boolean or binary digit":u+(r?" or not ["+(p?" negative, positive":" integer, integer")+" ]":"")))+": "+e,p=d=0,{name:"BigNumber Error",message:u,toString:function(){return this.name+": "+this.message}}}}function w(e,t,n,r){function l(e,r){var i,s=0,o=e.length,u,a=[0];for(r=r||n;s<o;s++){for(u=a.length,i=0;i<u;a[i]*=r,i++);for(a[0]+=h.indexOf(e.charAt(s)),i=0;i<a.length;i++)a[i]>t-1&&(a[i+1]==null&&(a[i+1]=0),a[i+1]+=a[i]/t^0,a[i]%=t)}return a.reverse()}function c(e){var t=0,n=e.length,r="";for(;t<n;r+=h.charAt(e[t++]));return r}var i,s,o,u,a,f;e=e.toLowerCase();if((i=e.indexOf("."))>-1){i=e.length-i-1,s=l((new y(n)).pow(i).toF(),10),u=e.split("."),o=l(u[1]),u=l(u[0]),f=E(o,s,o.length-s.length,r,t,u[u.length-1]&1),a=f.c;if(i=f.e){for(;++i;a.unshift(0));e=c(u)+"."+c(a)}else a[0]?u[i=u.length-1]<t-1?(++u[i],e=c(u)):e=(new y(c(u),t)).plus(g).toS(t):e=c(u)}else e=c(l(e));return e}function E(e,t,n,i,s,o){var f,l,c,h,p,d=t.slice(),v=f=t.length,m=e.length,b=e.slice(0,f),w=b.length,E=new y(g),S=E.c=[],T=0,N=r+(E.e=n)+1;E.s=i,i=N<0?0:N;for(;w++<f;b.push(0));d.unshift(0);do{for(c=0;c<s;c++){if(f!=(w=b.length))h=f>w?1:-1;else for(p=-1,h=0;++p<f;)if(t[p]!=b[p]){h=t[p]>b[p]?1:-1;break}if(!(h<0))break;for(l=w==f?t:d;w;){if(b[--w]<l[w]){for(p=w;p&&!b[--p];b[p]=s-1);--b[p],b[w]+=s}b[w]-=l[w]}for(;!b[0];b.shift());}S[T++]=h?c:++c,b[0]&&h?b[w]=e[v]||0:b=[e[v]]}while((v++<m||b[0]!=null)&&i--);return!S[0]&&T!=1&&(--E.e,S.shift()),T>N&&x(E,r,s,o,b[0]!=null),E.e>a?E.c=E.e=null:E.e<u&&(E.c=[E.e=0]),E}function S(e,t,n){var r=t-(e=new y(e)).e,i=e.c;if(!i)return e.toS();i.length>++t&&x(e,r,10),r=i[0]==0?r+1:n?t:e.e+r+1;for(;i.length<r;i.push(0));return r=e.e,n==1||n==2&&(--t<r||r<=s)?(e.s<0&&i[0]?"-":"")+(i.length>1?(i.splice(1,0,"."),i.join("")):i[0])+(r<0?"e":"e+")+r:e.toS()}function x(e,t,n,r,s){var o=e.c,u=e.s<0,a=n/2,f=e.e+t+1,l=o[f],c=s||f<0||o[f+1]!=null;s=i<4?(l!=null||c)&&(i==0||i==2&&!u||i==3&&u):l>a||l==a&&(i==4||c||i==6&&(o[f-1]&1||!t&&r)||i==7&&!u||i==8&&u);if(f<1||!o[0])return o.length=0,o.push(0),s?(o[0]=1,e.e=-t):e.e=0,e;o.length=f--;if(s)for(--n;++o[f]>n;)o[f]=0,f--||(++e.e,o.unshift(1));for(f=o.length;!o[--f];o.pop());return e}function T(e,t,n){var r=i;return i=n,e=new y(e),e.c&&x(e,t,10),i=r,e}var t=1e9,n=1e6,r=20,i=4,s=-7,o=21,u=-t,a=t,f=!0,l=parseInt,c=y.prototype,h="0123456789abcdefghijklmnopqrstuvwxyz",p,d=0,v=/^-?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i,m=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},g=y(1);y.ROUND_UP=0,y.ROUND_DOWN=1,y.ROUND_CEIL=2,y.ROUND_FLOOR=3,y.ROUND_HALF_UP=4,y.ROUND_HALF_DOWN=5,y.ROUND_HALF_EVEN=6,y.ROUND_HALF_CEIL=7,y.ROUND_HALF_FLOOR=8,y.config=function(){var e,n,c=0,h={},v=arguments,m=v[0],g="config",y=function(e,t,n){return!((p=e<t||e>n)||l(e)!=e&&e!==0)},w=m&&typeof m=="object"?function(){if(m.hasOwnProperty(n))return(e=m[n])!=null}:function(){if(v.length>c)return(e=v[c++])!=null};return w(n="DECIMAL_PLACES")&&(y(e,0,t)?r=e|0:b(e,n,g)),h[n]=r,w(n="ROUNDING_MODE")&&(y(e,0,8)?i=e|0:b(e,n,g)),h[n]=i,w(n="EXPONENTIAL_AT")&&(y(e,-t,t)?s=-(o=~~(e<0?-e:+e)):!p&&e&&y(e[0],-t,0)&&y(e[1],0,t)?(s=~~e[0],o=~~e[1]):b(e,n,g,1)),h[n]=[s,o],w(n="RANGE")&&(y(e,-t,t)&&~~e?u=-(a=~~(e<0?-e:+e)):!p&&e&&y(e[0],-t,-1)&&y(e[1],1,t)?(u=~~e[0],a=~~e[1]):b(e,n,g,1,1)),h[n]=[u,a],w(n="ERRORS")&&(e===!!e||e===1||e===0?l=(p=d=0,f=!!e)?parseInt:parseFloat:b(e,n,g,0,0,1)),h[n]=f,h},c.abs=c.absoluteValue=function(){var e=new y(this);return e.s<0&&(e.s=1),e},c.ceil=function(){return T(this,0,2)},c.comparedTo=c.cmp=function(e,t){var n,r=this,i=r.c,s=(d=-d,e=new y(e,t)).c,o=r.s,u=e.s,a=r.e,f=e.e;if(!o||!u)return null;n=i&&!i[0],t=s&&!s[0];if(n||t)return n?t?0:-u:o;if(o!=u)return o;if(n=o<0,t=a==f,!i||!s)return t?0:!i^n?1:-1;if(!t)return a>f^n?1:-1;for(o=-1,u=(a=i.length)<(f=s.length)?a:f;++o<u;)if(i[o]!=s[o])return i[o]>s[o]^n?1:-1;return a==f?0:a>f^n?1:-1},c.dividedBy=c.div=function(e,t){var n=this.c,r=this.e,i=this.s,s=(d=2,e=new y(e,t)).c,o=e.e,u=e.s,a=i==u?1:-1;return!r&&(!n||!n[0])||!o&&(!s||!s[0])?new y(!i||!u||(n?s&&n[0]==s[0]:!s)?NaN:n&&n[0]==0||!s?a*0:a/0):E(n,s,r-o,a,10)},c.equals=c.eq=function(e,t){return d=3,this.cmp(e,t)===0},c.floor=function(){return T(this,0,3)},c.greaterThan=c.gt=function(e,t){return d=4,this.cmp(e,t)>0},c.greaterThanOrEqualTo=c.gte=function(e,t){return d=5,(t=this.cmp(e,t))==1||t===0},c.isFinite=c.isF=function(){return!!this.c},c.isNaN=function(){return!this.s},c.isNegative=c.isNeg=function(){return this.s<0},c.isZero=c.isZ=function(){return!!this.c&&this.c[0]==0},c.lessThan=c.lt=function(e,t){return d=6,this.cmp(e,t)<0},c.lessThanOrEqualTo=c.lte=function(e,t){return d=7,(t=this.cmp(e,t))==-1||t===0},c.minus=function(e,t){var n,r,i,s,o=this,a=o.s;t=(d=8,e=new y(e,t)).s;if(!a||!t)return new y(NaN);if(a!=t)return e.s=-t,o.plus(e);var f=o.c,l=o.e,c=e.c,h=e.e;if(!l||!h){if(!f||!c)return f?(e.s=-t,e):new y(c?o:NaN);if(!f[0]||!c[0])return c[0]?(e.s=-t,e):new y(f[0]?o:0)}if(f=f.slice(),a=l-h){n=(s=a<0)?(a=-a,f):(h=l,c);for(n.reverse(),t=a;t--;n.push(0));n.reverse()}else{i=((s=f.length<c.length)?f:c).length;for(a=t=0;t<i;t++)if(f[t]!=c[t]){s=f[t]<c[t];break}}s&&(n=f,f=c,c=n,e.s=-e.s);if((t=-((i=f.length)-c.length))>0)for(;t--;f[i++]=0);for(t=c.length;t>a;){if(f[--t]<c[t]){for(r=t;r&&!f[--r];f[r]=9);--f[r],f[t]+=10}f[t]-=c[t]}for(;f[--i]==0;f.pop());for(;f[0]==0;f.shift(),--h);if(h<u||!f[0])f=[h=0];return e.c=f,e.e=h,e},c.modulo=c.mod=function(e,t){var n=this,s=n.c,o=(d=9,e=new y(e,t)).c,u=n.s,a=e.s;return t=!u||!a||o&&!o[0],t||s&&!s[0]?new y(t?NaN:n):(n.s=e.s=1,t=e.cmp(n)==1,n.s=u,e.s=a,t?new y(n):(u=r,a=i,r=0,i=1,n=n.div(e),r=u,i=a,this.minus(n.times(e))))},c.negated=c.neg=function(){var e=new y(this);return e.s=-e.s||null,e},c.plus=function(e,t){var n,r=this,i=r.s;t=(d=10,e=new y(e,t)).s;if(!i||!t)return new y(NaN);if(i!=t)return e.s=-t,r.minus(e);var s=r.e,o=r.c,u=e.e,f=e.c;if(!s||!u){if(!o||!f)return new y(i/0);if(!o[0]||!f[0])return f[0]?e:new y(o[0]?r:i*0)}if(o=o.slice(),i=s-u){n=i>0?(u=s,f):(i=-i,o);for(n.reverse();i--;n.push(0));n.reverse()}o.length-f.length<0&&(n=f,f=o,o=n);for(i=f.length,t=0;i;t=(o[--i]=o[i]+f[i]+t)/10^0,o[i]%=10);t&&(o.unshift(t),++u>a&&(o=u=null));for(i=o.length;o[--i]==0;o.pop());return e.c=o,e.e=u,e},c.toPower=c.pow=function(e){var t=e*0==0?e|0:e,r=new y(this),i=new y(g);if(((p=e<-n||e>n)&&(t=e*1/0)||l(e)!=e&&e!==0&&!(t=NaN))&&!b(e,"exponent","pow")||!t)return new y(Math.pow(r.toS(),t));for(t=t<0?-t:t;;){t&1&&(i=i.times(r)),t>>=1;if(!t)break;r=r.times(r)}return e<0?g.div(i):i},c.round=function(e,n){return e=e==null||((p=e<0||e>t)||l(e)!=e)&&!b(e,"decimal places","round")?0:e|0,n=n==null||((p=n<0||n>8)||l(n)!=n&&n!==0)&&!b(n,"mode","round")?i:n|0,T(this,e,n)},c.squareRoot=c.sqrt=function(){var e,t,n,i=this,s=i.c,o=i.s,u=i.e,a=new y("0.5");if(o!==1||!s||!s[0])return new y(!o||o<0&&(!s||s[0])?NaN:s?i:1/0);o=Math.sqrt(i.toS()),o==0||o==1/0?(e=s.join(""),e.length+u&1||(e+="0"),t=new y(Math.sqrt(e).toString()),t.e=((u+1)/2|0)-(u<0||u&1)):t=new y(o.toString()),o=t.e+(r+=4);do n=t,t=a.times(n.plus(i.div(n)));while(n.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return x(t,r-=4,10),t},c.times=function(e,t){var n,r=this,i=r.c,s=(d=11,e=new y(e,t)).c,o=r.e,f=e.e,l=r.s;e.s=l==(t=e.s)?1:-1;if(!o&&(!i||!i[0])||!f&&(!s||!s[0]))return new y(!l||!t||i&&!i[0]&&!s||s&&!s[0]&&!i?NaN:!i||!s?e.s/0:e.s*0);e.e=o+f,(l=i.length)<(t=s.length)&&(n=i,i=s,s=n,f=l,l=t,t=f);for(f=l+t,n=[];f--;n.push(0));for(o=t-1;o>-1;o--){for(t=0,f=l+o;f>o;t=n[f]+s[o]*i[f-o-1]+t,n[f--]=t%10|0,t=t/10|0);t&&(n[f]=(n[f]+t)%10)}t&&++e.e,!n[0]&&n.shift();for(f=n.length;!n[--f];n.pop());return e.c=e.e>a?e.e=null:e.e<u?[e.e=0]:n,e},c.toExponential=c.toE=function(e){return S(this,(e==null||((p=e<0||e>t)||l(e)!=e&&e!==0)&&!b(e,"decimal places","toE"))&&this.c?this.c.length-1:e|0,1)},c.toFixed=c.toF=function(e){var n,r,i,u=this;return e==null||((p=e<0||e>t)||l(e)!=e&&e!==0)&&!b(e,"decimal places","toF")||(i=u.e+(e|0)),n=s,e=o,s=-(o=1/0),i==r?r=u.toS():(r=S(u,i),u.s<0&&u.c&&(u.c[0]?r.indexOf("-")<0&&(r="-"+r):r=r.replace(/^-/,""))),s=n,o=e,r},c.toFraction=c.toFr=function(e){var t,n,s,o,u,l,c,h=o=new y(g),v=s=new y("0"),m=this,w=m.c,E=a,S=r,x=i,T=new y(g);if(!w)return m.toS();c=T.e=w.length-m.e-1;if(e==null||(!(d=12,l=new y(e)).s||(p=l.cmp(h)<0||!l.c)||f&&l.e<l.c.length-1)&&!b(e,"max denominator","toFr")||(e=l).cmp(T)>0)e=c>0?T:h;a=1/0,l=new y(w.join(""));for(r=0,i=1;;){t=l.div(T),u=o.plus(t.times(v));if(u.cmp(e)==1)break;o=v,v=u,h=s.plus(t.times(u=h)),s=u,T=l.minus(t.times(u=T)),l=u}return u=e.minus(o).div(v),s=s.plus(u.times(h)),o=o.plus(u.times(v)),s.s=h.s=m.s,r=c*2,i=x,n=h.div(v).minus(m).abs().cmp(s.div(o).minus(m).abs())<1?[h.toS(),v.toS()]:[s.toS(),o.toS()],a=E,r=S,n},c.toPrecision=c.toP=function(e){return e==null||((p=e<1||e>t)||l(e)!=e)&&!b(e,"precision","toP")?this.toS():S(this,--e|0,2)},c.toString=c.toS=function(e){var t,n,r,i=this,u=i.e;if(u===null)n=i.s?"Infinity":"NaN";else{if(e===t&&(u<=s||u>=o))return S(i,i.c.length-1,1);n=i.c.join("");if(u<0){for(;++u;n="0"+n);n="0."+n}else if(r=n.length,u>0)if(++u>r)for(u-=r;u--;n+="0");else u<r&&(n=n.slice(0,u)+"."+n.slice(u));else if(t=n.charAt(0),r>1)n=t+"."+n.slice(1);else if(t=="0")return t;if(e!=null)if((p=!(e>=2&&e<=36))||e!=(e|0)&&!!f)b(e,"base","toS");else{n=w(n,e|0,10,i.s);if(n=="0")return n}}return i.s<0?"-"+n:n},c.valueOf=function(){return this.toS()},typeof module!="undefined"&&module.exports?module.exports=y:typeof define=="function"&&define.amd?define(function(){return y}):e.BigNumber=y})(this); | ||
/* bignumber.js v1.1.0 https://github.com/MikeMcl/bignumber.js/LICENCE */(function(n){"use strict";function t(n,i){var c,l,a,w,p,o=this;if(!(o instanceof t))return new t(n,i);if(n instanceof t)if(r=0,i!==c)n+="";else{o.s=n.s;o.e=n.e;o.c=(n=n.c)?n.slice():n;return}if(typeof n!="string"&&(n=(a=typeof n=="number"||Object.prototype.toString.call(n)=="[object Number]")&&n===0&&1/n<0?"-0":n+""),i===c&&g.test(n))o.s=n.charAt(0)=="-"?(n=n.slice(1),-1):1;else{if(i==10)return k(n,s,u);if(n=rt.call(n).replace(/^\+(?!-)/,""),o.s=n.charAt(0)=="-"?(n=n.replace(/^-(?!-)/,""),-1):1,i!=null?i!=(i|0)&&y||(e=!(i>=2&&i<=36))?(f(i,2),p=g.test(n)):(w="["+d.slice(0,i=i|0)+"]+",n=n.replace(/\.$/,"").replace(/^\./,"0."),(p=new RegExp("^"+w+"(?:\\."+w+")?$","i").test(n))?(a&&(n.replace(".","").length>15&&f(n,0),a=!a),n=tt(n,10,i,o.s)):n!="Infinity"&&n!="NaN"&&(f(n,1,i),n="NaN")):p=g.test(n),!p){o.c=o.e=null;n!="Infinity"&&(n!="NaN"&&f(n,3),o.s=null);r=0;return}}for((c=n.indexOf("."))>-1&&(n=n.replace(".","")),(l=n.search(/e/i))>0?(c<0&&(c=l),c+=+n.slice(l+1),n=n.substring(0,l)):c<0&&(c=n.length),(i=n.length,a&&i>15)&&f(n,0),l=r=0;n.charAt(l)=="0";l++);if((c-=l+1)>h)o.c=o.e=null;else if(l==i||c<v)o.c=[o.e=0];else{for(;n.charAt(--i)=="0";);for(o.e=c,o.c=[],c=0;l<=i;o.c[c++]=+n.charAt(l++));}}function f(n,t,i,u,f,o){if(y){var s=["new BigNumber","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFr"][r?r<0?-r:r:1/r<0?1:0]+"()",h=e?" out of range":" not a"+(f?" non-zero":"n")+" integer";h=([s+" number type has more than 15 significant digits",s+" not a base "+i+" number",s+" base"+h,s+" not a number"][t]||i+"() "+t+(o?" not a boolean or binary digit":h+(u?" or not ["+(e?" negative, positive":" integer, integer")+" ]":"")))+": "+n;e=r=0;throw{name:"BigNumber Error",message:h,toString:function(){return this.name+": "+this.message}};}}function tt(n,i,r,u){function h(n,t){var u,e=0,s=n.length,o,f=[0];for(t=t||r;e<s;e++){for(o=f.length,u=0;u<o;f[u]*=t,u++);for(f[0]+=d.indexOf(n.charAt(e)),u=0;u<f.length;u++)f[u]>i-1&&(f[u+1]==null&&(f[u+1]=0),f[u+1]+=f[u]/i^0,f[u]%=i)}return f.reverse()}function o(n){for(var t=0,r=n.length,i="";t<r;i+=d.charAt(n[t++]));return i}var e,c,l,f,s,a;if(n=n.toLowerCase(),(e=n.indexOf("."))>-1)if(e=n.length-e-1,c=h(new t(r).pow(e).toF(),10),f=n.split("."),l=h(f[1]),f=h(f[0]),a=it(l,c,l.length-c.length,u,i,f[f.length-1]&1),s=a.c,e=a.e){for(;++e;s.unshift(0));n=o(f)+"."+o(s)}else s[0]?f[e=f.length-1]<i-1?(++f[e],n=o(f)):n=new t(o(f),i).plus(p).toS(i):n=o(f);else n=o(h(n));return n}function it(n,i,r,u,f,e){var y,d,k,w,a,rt=i.slice(),g=y=i.length,ut=n.length,o=n.slice(0,y),c=o.length,l=new t(p),nt=l.c=[],tt=0,it=s+(l.e=r)+1;for(l.s=u,u=it<0?0:it;c++<y;o.push(0));rt.unshift(0);do{for(k=0;k<f;k++){if(y!=(c=o.length))w=y>c?1:-1;else for(a=-1,w=0;++a<y;)if(i[a]!=o[a]){w=i[a]>o[a]?1:-1;break}if(w<0){for(d=c==y?i:rt;c;){if(o[--c]<d[c]){for(a=c;a&&!o[--a];o[a]=f-1);--o[a];o[c]+=f}o[c]-=d[c]}for(;!o[0];o.shift());}else break}nt[tt++]=w?k:++k;o[0]&&w?o[c]=n[g]||0:o=[n[g]]}while((g++<ut||o[0]!=null)&&u--);return nt[0]||tt==1||(--l.e,nt.shift()),tt>it&&b(l,s,f,e,o[0]!=null),l.e>h?l.c=l.e=null:l.e<v&&(l.c=[l.e=0]),l}function w(n,i,r){var u=i-(n=new t(n)).e,f=n.c;if(!f)return n.toS();for(f.length>++i&&b(n,u,10),u=f[0]==0?u+1:r?i:n.e+u+1;f.length<u;f.push(0));return u=n.e,r==1||r==2&&(--i<u||u<=c)?(n.s<0&&f[0]?"-":"")+(f.length>1?(f.splice(1,0,"."),f.join("")):f[0])+(u<0?"e":"e+")+u:n.toS()}function b(n,t,i,r,f){var e=n.c,s=n.s<0,c=i/2,o=n.e+t+1,h=e[o],l=f||o<0||e[o+1]!=null;if(f=u<4?(h!=null||l)&&(u==0||u==2&&!s||u==3&&s):h>c||h==c&&(u==4||l||u==6&&(e[o-1]&1||!t&&r)||u==7&&!s||u==8&&s),o<1||!e[0])return e.length=0,e.push(0),f?(e[0]=1,n.e=-t):n.e=0,n;if(e.length=o--,f)for(--i;++e[o]>i;)e[o]=0,o--||(++n.e,e.unshift(1));for(o=e.length;!e[--o];e.pop());return n}function k(n,i,r){var f=u;return u=r,n=new t(n),n.c&&b(n,i,10),u=f,n}var o=1e9,nt=1e6,s=20,u=4,c=-7,a=21,v=-o,h=o,y=!0,l=parseInt,i=t.prototype,d="0123456789abcdefghijklmnopqrstuvwxyz",e,r=0,g=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,rt=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},p=t(1);t.ROUND_UP=0;t.ROUND_DOWN=1;t.ROUND_CEIL=2;t.ROUND_FLOOR=3;t.ROUND_HALF_UP=4;t.ROUND_HALF_DOWN=5;t.ROUND_HALF_EVEN=6;t.ROUND_HALF_CEIL=7;t.ROUND_HALF_FLOOR=8;t.config=function(){var n,t,g=0,p={},d=arguments,k=d[0],w="config",i=function(n,t,i){return!((e=n<t||n>i)||l(n)!=n&&n!==0)},b=k&&typeof k=="object"?function(){if(k.hasOwnProperty(t))return(n=k[t])!=null}:function(){if(d.length>g)return(n=d[g++])!=null};return b(t="DECIMAL_PLACES")&&(i(n,0,o)?s=n|0:f(n,t,w)),p[t]=s,b(t="ROUNDING_MODE")&&(i(n,0,8)?u=n|0:f(n,t,w)),p[t]=u,b(t="EXPONENTIAL_AT")&&(i(n,-o,o)?c=-(a=~~(n<0?-n:+n)):!e&&n&&i(n[0],-o,0)&&i(n[1],0,o)?(c=~~n[0],a=~~n[1]):f(n,t,w,1)),p[t]=[c,a],b(t="RANGE")&&(i(n,-o,o)&&~~n?v=-(h=~~(n<0?-n:+n)):!e&&n&&i(n[0],-o,-1)&&i(n[1],1,o)?(v=~~n[0],h=~~n[1]):f(n,t,w,1,1)),p[t]=[v,h],b(t="ERRORS")&&(n===!!n||n===1||n===0?l=(e=r=0,y=!!n)?parseInt:parseFloat:f(n,t,w,0,0,1)),p[t]=y,p};i.abs=i.absoluteValue=function(){var n=new t(this);return n.s<0&&(n.s=1),n};i.ceil=function(){return k(this,0,2)};i.comparedTo=i.cmp=function(n,i){var f,l=this,e=l.c,o=(r=-r,n=new t(n,i)).c,u=l.s,c=n.s,s=l.e,h=n.e;if(!u||!c)return null;if(f=e&&!e[0],i=o&&!o[0],f||i)return f?i?0:-c:u;if(u!=c)return u;if(f=u<0,i=s==h,!e||!o)return i?0:!e^f?1:-1;if(!i)return s>h^f?1:-1;for(u=-1,c=(s=e.length)<(h=o.length)?s:h;++u<c;)if(e[u]!=o[u])return e[u]>o[u]^f?1:-1;return s==h?0:s>h^f?1:-1};i.dividedBy=i.div=function(n,i){var u=this.c,o=this.e,s=this.s,f=(r=2,n=new t(n,i)).c,h=n.e,c=n.s,e=s==c?1:-1;return!o&&(!u||!u[0])||!h&&(!f||!f[0])?new t(!s||!c||(u?f&&u[0]==f[0]:!f)?NaN:u&&u[0]==0||!f?e*0:e/0):it(u,f,o-h,e,10)};i.equals=i.eq=function(n,t){return r=3,this.cmp(n,t)===0};i.floor=function(){return k(this,0,3)};i.greaterThan=i.gt=function(n,t){return r=4,this.cmp(n,t)>0};i.greaterThanOrEqualTo=i.gte=function(n,t){return r=5,(t=this.cmp(n,t))==1||t===0};i.isFinite=i.isF=function(){return!!this.c};i.isNaN=function(){return!this.s};i.isNegative=i.isNeg=function(){return this.s<0};i.isZero=i.isZ=function(){return!!this.c&&this.c[0]==0};i.lessThan=i.lt=function(n,t){return r=6,this.cmp(n,t)<0};i.lessThanOrEqualTo=i.lte=function(n,t){return r=7,(t=this.cmp(n,t))==-1||t===0};i.minus=function(n,i){var s,c,l,a,h=this,e=h.s;if(i=(r=8,n=new t(n,i)).s,!e||!i)return new t(NaN);if(e!=i)return n.s=-i,h.plus(n);var u=h.c,y=h.e,f=n.c,o=n.e;if(!y||!o){if(!u||!f)return u?(n.s=-i,n):new t(f?h:NaN);if(!u[0]||!f[0])return f[0]?(n.s=-i,n):new t(u[0]?h:0)}if(u=u.slice(),e=y-o){for(s=(a=e<0)?(e=-e,u):(o=y,f),s.reverse(),i=e;i--;s.push(0));s.reverse()}else for(l=((a=u.length<f.length)?u:f).length,e=i=0;i<l;i++)if(u[i]!=f[i]){a=u[i]<f[i];break}if(a&&(s=u,u=f,f=s,n.s=-n.s),(i=-((l=u.length)-f.length))>0)for(;i--;u[l++]=0);for(i=f.length;i>e;){if(u[--i]<f[i]){for(c=i;c&&!u[--c];u[c]=9);--u[c];u[i]+=10}u[i]-=f[i]}for(;u[--l]==0;u.pop());for(;u[0]==0;u.shift(),--o);return(o<v||!u[0])&&(u=[o=0]),n.c=u,n.e=o,n};i.modulo=i.mod=function(n,i){var f=this,h=f.c,c=(r=9,n=new t(n,i)).c,e=f.s,o=n.s;return(i=!e||!o||c&&!c[0],i||h&&!h[0])?new t(i?NaN:f):(f.s=n.s=1,i=n.cmp(f)==1,f.s=e,n.s=o,i?new t(f):(e=s,o=u,s=0,u=1,f=f.div(n),s=e,u=o,this.minus(f.times(n))))};i.negated=i.neg=function(){var n=new t(this);return n.s=-n.s||null,n};i.plus=function(n,i){var o,c=this,f=c.s;if(i=(r=10,n=new t(n,i)).s,!f||!i)return new t(NaN);if(f!=i)return n.s=-i,c.minus(n);var l=c.e,u=c.c,s=n.e,e=n.c;if(!l||!s){if(!u||!e)return new t(f/0);if(!u[0]||!e[0])return e[0]?n:new t(u[0]?c:f*0)}if(u=u.slice(),f=l-s){for(o=f>0?(s=l,e):(f=-f,u),o.reverse();f--;o.push(0));o.reverse()}for(u.length-e.length<0&&(o=e,e=u,u=o),f=e.length,i=0;f;i=(u[--f]=u[f]+e[f]+i)/10^0,u[f]%=10);for(i&&(u.unshift(i),++s>h&&(u=s=null)),f=u.length;u[--f]==0;u.pop());return n.c=u,n.e=s,n};i.toPower=i.pow=function(n){var i=n*0==0?n|0:n,r=new t(this),u=new t(p);if(((e=n<-nt||n>nt)&&(i=n/0)||l(n)!=n&&n!==0&&!(i=NaN))&&!f(n,"exponent","pow")||!i)return new t(Math.pow(r.toS(),i));for(i=i<0?-i:i;;){if(i&1&&(u=u.times(r)),i>>=1,!i)break;r=r.times(r)}return n<0?p.div(u):u};i.round=function(n,t){return n=n==null||((e=n<0||n>o)||l(n)!=n)&&!f(n,"decimal places","round")?0:n|0,t=t==null||((e=t<0||t>8)||l(t)!=t&&t!==0)&&!f(t,"mode","round")?u:t|0,k(this,n,t)};i.squareRoot=i.sqrt=function(){var f,i,e,r=this,u=r.c,n=r.s,o=r.e,h=new t("0.5");if(n!==1||!u||!u[0])return new t(!n||n<0&&(!u||u[0])?NaN:u?r:1/0);n=Math.sqrt(r.toS());n==0||n==1/0?(f=u.join(""),f.length+o&1||(f+="0"),i=new t(Math.sqrt(f).toString()),i.e=((o+1)/2|0)-(o<0||o&1)):i=new t(n.toString());n=i.e+(s+=4);do e=i,i=h.times(e.plus(r.div(e)));while(e.c.slice(0,n).join("")!==i.c.slice(0,n).join(""));return b(i,s-=4,10),i};i.times=function(n,i){var f,l=this,e=l.c,o=(r=11,n=new t(n,i)).c,s=l.e,u=n.e,c=l.s;if(n.s=c==(i=n.s)?1:-1,!s&&(!e||!e[0])||!u&&(!o||!o[0]))return new t(!c||!i||e&&!e[0]&&!o||o&&!o[0]&&!e?NaN:!e||!o?n.s/0:n.s*0);for(n.e=s+u,(c=e.length)<(i=o.length)&&(f=e,e=o,o=f,u=c,c=i,i=u),u=c+i,f=[];u--;f.push(0));for(s=i-1;s>-1;s--){for(i=0,u=c+s;u>s;i=f[u]+o[s]*e[u-s-1]+i,f[u--]=i%10|0,i=i/10|0);i&&(f[u]=(f[u]+i)%10)}for(i&&++n.e,f[0]||f.shift(),u=f.length;!f[--u];f.pop());return n.c=n.e>h?n.e=null:n.e<v?[n.e=0]:f,n};i.toExponential=i.toE=function(n){return w(this,(n==null||((e=n<0||n>o)||l(n)!=n&&n!==0)&&!f(n,"decimal places","toE"))&&this.c?this.c.length-1:n|0,1)};i.toFixed=i.toF=function(n){var u,t,r,i=this;return n==null||((e=n<0||n>o)||l(n)!=n&&n!==0)&&!f(n,"decimal places","toF")||(r=i.e+(n|0)),u=c,n=a,c=-(a=1/0),r==t?t=i.toS():(t=w(i,r),i.s<0&&i.c&&(i.c[0]?t.indexOf("-")<0&&(t="-"+t):t=t.replace(/^-/,""))),c=u,a=n,t};i.toFraction=i.toFr=function(n){var k,nt,c,l,i,o,d,a=l=new t(p),v=c=new t("0"),w=this,g=w.c,tt=h,it=s,rt=u,b=new t(p);if(!g)return w.toS();for(d=b.e=g.length-w.e-1,(n==null||(!(r=12,o=new t(n)).s||(e=o.cmp(a)<0||!o.c)||y&&o.e<o.c.length-1)&&!f(n,"max denominator","toFr")||(n=o).cmp(b)>0)&&(n=d>0?b:a),h=1/0,o=new t(g.join("")),s=0,u=1;;){if(k=o.div(b),i=l.plus(k.times(v)),i.cmp(n)==1)break;l=v;v=i;a=c.plus(k.times(i=a));c=i;b=o.minus(k.times(i=b));o=i}return i=n.minus(l).div(v),c=c.plus(i.times(a)),l=l.plus(i.times(v)),c.s=a.s=w.s,s=d*2,u=rt,nt=a.div(v).minus(w).abs().cmp(c.div(l).minus(w).abs())<1?[a.toS(),v.toS()]:[c.toS(),l.toS()],h=tt,s=it,nt};i.toPrecision=i.toP=function(n){return n==null||((e=n<1||n>o)||l(n)!=n)&&!f(n,"precision","toP")?this.toS():w(this,--n|0,2)};i.toString=i.toS=function(n){var u,t,o,r=this,i=r.e;if(i===null)t=r.s?"Infinity":"NaN";else{if(n===u&&(i<=c||i>=a))return w(r,r.c.length-1,1);if(t=r.c.join(""),i<0){for(;++i;t="0"+t);t="0."+t}else if(o=t.length,i>0)if(++i>o)for(i-=o;i--;t+="0");else i<o&&(t=t.slice(0,i)+"."+t.slice(i));else if(u=t.charAt(0),o>1)t=u+"."+t.slice(1);else if(u=="0")return u;if(n!=null)if((e=!(n>=2&&n<=36))||n!=(n|0)&&y)f(n,"base","toS");else if(t=tt(t,n|0,10,r.s),t=="0")return t}return r.s<0?"-"+t:t};i.valueOf=function(){return this.toS()};typeof module!="undefined"&&module.exports?module.exports=t:typeof define=="function"&&define.amd?define(function(){return t}):n.BigNumber=t})(this) |
{ | ||
"name": "bignumber.js", | ||
"description": "A library for arbitrary-precision decimal and non-decimal arithmetic", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "arbitrary", |
# bignumber.js # | ||
A Javascript library for arbitrary-precision decimal and non-decimal arithmetic. | ||
A JavaScript library for arbitrary-precision decimal and non-decimal arithmetic. | ||
## Features | ||
- Faster, smaller, and perhaps easier to use than Javascript versions of Java's BigDecimal | ||
- Faster, smaller, and perhaps easier to use than JavaScript versions of Java's BigDecimal | ||
- 5 KB minified and gzipped | ||
- Simple API but full-featured | ||
- Works with numbers with or without fraction digits in bases from 2 to 36 inclusive | ||
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of Javascript's Number type | ||
- Replicates the `toExponential`, `toFixed`, `toPrecision` and `toString` methods of JavaScript's Number type | ||
- Includes a `toFraction` and a `squareRoot` method | ||
@@ -24,4 +24,3 @@ - Stores values in an accessible decimal floating point format | ||
The library is the single Javascript file *bignumber.js* | ||
(or *bignumber.min.js*, which is *bignumber.js* minified using uglify-js). | ||
The library is the single JavaScript file *bignumber.js* (or minified, *bignumber.min.js*). | ||
@@ -45,3 +44,2 @@ It can be loaded via a script tag in an HTML document for the browser | ||
will install this entire directory in a *node_modules* directory within the current directory. | ||
It can then be loaded with `require('bignumber.js')`. | ||
@@ -90,3 +88,3 @@ To load with AMD loader libraries such as [requireJS](http://requirejs.org/): | ||
Like Javascript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods | ||
Like JavaScript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods | ||
@@ -159,3 +157,3 @@ x = new BigNumber(255.5) | ||
*bignumber-vs-number.html* enables some of the methods of bignumber.js to be compared with those of Javascript's Number type. | ||
*bignumber-vs-number.html* enables some of the methods of bignumber.js to be compared with those of JavaScript's Number type. | ||
@@ -166,3 +164,3 @@ ## Performance | ||
*bignumber-vs-bigdecimal.html* tests the performance of bignumber.js against the Javascript translations of two versions of BigDecimal, its use should be more or less self-explanatory. | ||
*bignumber-vs-bigdecimal.html* tests the performance of bignumber.js against the JavaScript translations of two versions of BigDecimal, its use should be more or less self-explanatory. | ||
(The GWT version doesn't work in IE 6.) | ||
@@ -206,3 +204,3 @@ | ||
Michael Mclaughlin | ||
Michael | ||
<a href="mailto:M8ch88l@gmail.com">M8ch88l@gmail.com</a> | ||
@@ -220,10 +218,11 @@ | ||
####1.1.0 | ||
* 1/8/2013 Allow numbers with trailing radix point. | ||
####1.0.1 | ||
* Bugfix: error messages with incorrect method name | ||
* Corrected a couple of spelling mistakes in comments | ||
* Very minor regex tweaks | ||
####1.0.0 | ||
* 8/11/2012 Initial release | ||
* 8/11/2012 Initial release | ||
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/50b85fd919b406ef9312551092a95fb7 "githalytics.com")](http://githalytics.com/MikeMcl/bignumber.js) |
@@ -481,2 +481,6 @@ var count = (function config(BigNumber) { | ||
assert('0', new BigNumber(-0).toS()); | ||
assert('0', new BigNumber('.0').toS()); | ||
assert('0', new BigNumber('0.').toS()); | ||
assert('0', new BigNumber('-0.').toS()); | ||
assert('0', new BigNumber('+0.').toS()); | ||
assert('0', new BigNumber('+0').toS()); | ||
@@ -501,2 +505,3 @@ assert('0', new BigNumber('-0').toS()); | ||
assertException(function () {new BigNumber('.+0')}, ".+0"); | ||
assertException(function () {new BigNumber('0 .')}, "0 ."); | ||
assertException(function () {new BigNumber('. 0')}, ". 0"); | ||
@@ -515,2 +520,6 @@ assertException(function () {new BigNumber('..0')}, "..0"); | ||
assert('-2', new BigNumber(' -2 ').toS()); | ||
assert('0.2', new BigNumber('.2').toS()); | ||
assert('2', new BigNumber('2.').toS()); | ||
assert('-2', new BigNumber('-2.').toS()); | ||
assert('2', new BigNumber('+2.').toS()); | ||
assert('0.2', new BigNumber('+.2').toS()); | ||
@@ -529,2 +538,3 @@ assert('-0.2', new BigNumber('-.2').toS()); | ||
assertException(function () {new BigNumber('.+2')}, ".+2"); | ||
assertException(function () {new BigNumber('2 .')}, "2 ."); | ||
assertException(function () {new BigNumber('. 2')}, ". 2"); | ||
@@ -531,0 +541,0 @@ assertException(function () {new BigNumber('..2')}, "..2"); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6327951
70953
222