From f6a69c366cf89dc38c11b7af16ebca65107de884 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Thu, 25 Dec 2014 22:19:06 +0200 Subject: [PATCH] BigNumber replaced by Decimal Since this game only requires limited precision, Decimal is more suitable. It gives a HUGE boost in performance. Now it is possible to go up to the maximum value, 9.999...e+9000000000000000 --- index.html | 4 ++-- js/bignumber.min.js | 2 -- js/decimal.min.js | 2 ++ js/exponential.js | 21 ++++++++++----------- 4 files changed, 14 insertions(+), 15 deletions(-) delete mode 100644 js/bignumber.min.js create mode 100644 js/decimal.min.js diff --git a/index.html b/index.html index 2a8d36c..25b23a5 100644 --- a/index.html +++ b/index.html @@ -1,9 +1,9 @@ - +
-

True exponential v0.2

+

True exponential v0.3

Cash multiplier: {{(1+multiplier).toFixed(4)}}


diff --git a/js/bignumber.min.js b/js/bignumber.min.js deleted file mode 100644 index b1bf131..0000000 --- a/js/bignumber.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! bignumber.js v1.5.0 https://github.com/MikeMcl/bignumber.js/LICENCE */ -(function(n){"use strict";function i(n,t){var c,l,a,b,w,p,s=this;if(!(s instanceof i))return new i(n,t);if(n instanceof i)if(u=0,t!==c)n+="";else{s.s=n.s;s.e=n.e;s.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+""),p=n,t===c&&g.test(n))s.s=n.charAt(0)=="-"?(n=n.slice(1),-1):1;else{if(t==10)return k(n,e,r);if(n=rt.call(n).replace(/^\+(?!-)/,""),s.s=n.charAt(0)=="-"?(n=n.replace(/^-(?!-)/,""),-1):1,t!=null?t!=(t|0)&&y||(o=!(t>=2&&t<65))?(f(t,2),w=g.test(n)):(b="["+d.slice(0,t=t|0)+"]+",n=n.replace(/\.$/,"").replace(/^\./,"0."),(w=new RegExp("^"+b+"(?:\\."+b+")?$",t<37?"i":"").test(n))?(a&&(n.replace(/^0\.0*|\./,"").length>15&&f(p,0),a=!a),n=tt(n,10,t,s.s)):n!="Infinity"&&n!="NaN"&&(f(p,1,t),n="NaN")):w=g.test(n),!w){s.c=s.e=null;n!="Infinity"&&(n!="NaN"&&f(p,3),s.s=null);u=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),l=0;n.charAt(l)=="0";l++);if(t=n.length,a&&t>15&&n.slice(l).length>15&&f(p,0),u=0,(c-=l+1)>h)s.c=s.e=null;else if(l==t||ct-1&&(f[u+1]==null&&(f[u+1]=0),f[u+1]+=f[u]/t^0,f[u]%=t)}return f.reverse()}function o(n){for(var t=0,r=n.length,i="";t-1)if(e=n.length-e-1,c=h(new i(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,t,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]c?1:-1;else for(a=-1,w=0;++as[a]?1:-1;break}if(w<0){for(d=c==y?t:rt;c;){if(s[--c]it&&b(l,e,f,o,s[0]!=null),l.e>h?l.c=l.e=null:l.e++t&&b(n,u,10),u=f[0]==0?u+1:r?t:n.e+u+1;f.length1?(f.splice(1,0,"."),f.join("")):f[0])+(u<0?"e":"e+")+u:n.toS()}function b(n,t,i,u,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=r<4?(h!=null||l)&&(r==0||r==2&&!s||r==3&&s):h>c||h==c&&(r==4||l||r==6&&(e[o-1]&1||!t&&u)||r==7&&!s||r==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,t,u){var f=r;return r=u,n=new i(n),n.c&&b(n,t,10),r=f,n}var s=1e9,nt=1e6,e=20,r=4,c=-7,a=21,v=-s,h=s,y=!0,l=parseInt,t=i.prototype,d="0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_",o,u=0,g=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,rt=String.prototype.trim||function(){return this.replace(/^\s+|\s+$/g,"")},p=i(1);i.ROUND_UP=0;i.ROUND_DOWN=1;i.ROUND_CEIL=2;i.ROUND_FLOOR=3;i.ROUND_HALF_UP=4;i.ROUND_HALF_DOWN=5;i.ROUND_HALF_EVEN=6;i.ROUND_HALF_CEIL=7;i.ROUND_HALF_FLOOR=8;i.config=function(){var n,t,g=0,p={},d=arguments,k=d[0],w="config",i=function(n,t,i){return!((o=ni)||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,s)?e=n|0:f(n,t,w)),p[t]=e,b(t="ROUNDING_MODE")&&(i(n,0,8)?r=n|0:f(n,t,w)),p[t]=r,b(t="EXPONENTIAL_AT")&&(i(n,-s,s)?c=-(a=~~(n<0?-n:+n)):!o&&n&&i(n[0],-s,0)&&i(n[1],0,s)?(c=~~n[0],a=~~n[1]):f(n,t,w,1)),p[t]=[c,a],b(t="RANGE")&&(i(n,-s,s)&&~~n?v=-(h=~~(n<0?-n:+n)):!o&&n&&i(n[0],-s,-1)&&i(n[1],1,s)?(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=(o=u=0,y=!!n)?parseInt:parseFloat:f(n,t,w,0,0,1)),p[t]=y,p};t.abs=t.absoluteValue=function(){var n=new i(this);return n.s<0&&(n.s=1),n};t.ceil=function(){return k(this,0,2)};t.comparedTo=t.cmp=function(n,t){var f,l=this,e=l.c,o=(u=-u,n=new i(n,t)).c,r=l.s,c=n.s,s=l.e,h=n.e;if(!r||!c)return null;if(f=e&&!e[0],t=o&&!o[0],f||t)return f?t?0:-c:r;if(r!=c)return r;if(f=r<0,t=s==h,!e||!o)return t?0:!e^f?1:-1;if(!t)return s>h^f?1:-1;for(r=-1,c=(s=e.length)<(h=o.length)?s:h;++ro[r]^f?1:-1;return s==h?0:s>h^f?1:-1};t.decimalPlaces=t.dp=function(){var n;return this.c?(n=this.c.length-this.e-1,n<0?0:n):null};t.dividedBy=t.div=function(n,t){var r=this.c,o=this.e,s=this.s,f=(u=2,n=new i(n,t)).c,h=n.e,c=n.s,e=s==c?1:-1;return!o&&(!r||!r[0])||!h&&(!f||!f[0])?new i(!s||!c||(r?f&&r[0]==f[0]:!f)?NaN:r&&r[0]==0||!f?e*0:e/0):it(r,f,o-h,e,10)};t.equals=t.eq=function(n,t){return u=3,this.cmp(n,t)===0};t.floor=function(){return k(this,0,3)};t.greaterThan=t.gt=function(n,t){return u=4,this.cmp(n,t)>0};t.greaterThanOrEqualTo=t.gte=function(n,t){return u=5,(t=this.cmp(n,t))==1||t===0};t.isFinite=t.isF=function(){return!!this.c};t.isNaN=function(){return!this.s};t.isNegative=t.isNeg=function(){return this.s<0};t.isZero=t.isZ=function(){return!!this.c&&this.c[0]==0};t.lessThan=t.lt=function(n,t){return u=6,this.cmp(n,t)<0};t.lessThanOrEqualTo=t.lte=function(n,t){return u=7,(t=this.cmp(n,t))==-1||t===0};t.minus=function(n,t){var h,l,a,y,c=this,o=c.s;if(t=(u=8,n=new i(n,t)).s,!o||!t)return new i(NaN);if(o!=t)return n.s=-t,c.plus(n);var f=c.c,p=c.e,e=n.c,s=n.e;if(!p||!s){if(!f||!e)return f?(n.s=-t,n):new i(e?c:NaN);if(!f[0]||!e[0])return e[0]?(n.s=-t,n):new i(f[0]?c:r==3?-0:0)}if(f=f.slice(),o=p-s){for(h=(y=o<0)?(o=-o,f):(s=p,e),h.reverse(),t=o;t--;h.push(0));h.reverse()}else for(a=((y=f.length0)for(;t--;f[a++]=0);for(t=e.length;t>o;){if(f[--t]0?(s=l,e):(f=-f,r),o.reverse();f--;o.push(0));o.reverse()}for(r.length-e.length<0&&(o=e,e=r,r=o),f=e.length,t=0;f;t=(r[--f]=r[f]+e[f]+t)/10^0,r[f]%=10);for(t&&(r.unshift(t),++s>h&&(r=s=null)),f=r.length;r[--f]==0;r.pop());return n.c=r,n.e=s,n};t.toPower=t.pow=function(n){var t=n*0==0?n|0:n,r=new i(this),u=new i(p);if(((o=n<-nt||n>nt)&&(t=n/0)||l(n)!=n&&n!==0&&!(t=NaN))&&!f(n,"exponent","pow")||!t)return new i(Math.pow(r.toS(),t));for(t=t<0?-t:t;;){if(t&1&&(u=u.times(r)),t>>=1,!t)break;r=r.times(r)}return n<0?p.div(u):u};t.round=function(n,t){return n=n==null||((o=n<0||n>s)||l(n)!=n)&&!f(n,"decimal places","round")?0:n|0,t=t==null||((o=t<0||t>8)||l(t)!=t&&t!==0)&&!f(t,"mode","round")?r:t|0,k(this,n,t)};t.squareRoot=t.sqrt=function(){var o,u,c,s,h=this,n=h.c,t=h.s,f=h.e,l=e,a=r,v=new i("0.5");if(t!==1||!n||!n[0])return new i(!t||t<0&&(!n||n[0])?NaN:n?h:1/0);for(t=Math.sqrt(h.toS()),r=1,t==0||t==1/0?(o=n.join(""),o.length+f&1||(o+="0"),u=new i(Math.sqrt(o)+""),u.c||(u.c=[1]),u.e=((f+1)/2|0)-(f<0||f&1)):u=new i(o=t.toString()),c=u.e,t=c+(e+=4),t<3&&(t=0),f=t;;)if(s=u,u=v.times(s.plus(h.div(s))),s.c.slice(0,t).join("")===u.c.slice(0,t).join(""))if(n=u.c,t=t-(o&&u.ef-2&&(n.length=f-2),!u.times(u).eq(h))){while(n.length-1;s--){for(t=0,r=c+s;r>s;t=f[r]+o[s]*e[r-s-1]+t,f[r--]=t%10|0,t=t/10|0);t&&(f[r]=(f[r]+t)%10)}for(t&&++n.e,f[0]||f.shift(),r=f.length;!f[--r];f.pop());return n.c=n.e>h?n.e=null:n.es)||l(n)!=n&&n!==0)&&!f(n,"decimal places","toE"))&&this.c?this.c.length-1:n|0,1)};t.toFixed=t.toF=function(n){var u,t,r,i=this;return n==null||((o=n<0||n>s)||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};t.toFraction=t.toFr=function(n){var k,nt,c,l,t,s,d,a=l=new i(p),v=c=new i("0"),w=this,g=w.c,tt=h,it=e,rt=r,b=new i(p);if(!g)return w.toS();for(d=b.e=g.length-w.e-1,(n==null||(!(u=12,s=new i(n)).s||(o=s.cmp(a)<0||!s.c)||y&&s.e0)&&(n=d>0?b:a),h=1/0,s=new i(g.join("")),e=0,r=1;;){if(k=s.div(b),t=l.plus(k.times(v)),t.cmp(n)==1)break;l=v;v=t;a=c.plus(k.times(t=a));c=t;b=s.minus(k.times(t=b));s=t}return t=n.minus(l).div(v),c=c.plus(t.times(a)),l=l.plus(t.times(v)),c.s=a.s=w.s,e=d*2,r=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,e=it,nt};t.toPrecision=t.toP=function(n){return n==null||((o=n<1||n>s)||l(n)!=n)&&!f(n,"precision","toP")?this.toS():w(this,--n|0,2)};t.toString=t.toS=function(n){var u,t,e,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(e=t.length,i>0)if(++i>e)for(i-=e;i--;t+="0");else i1)t=u+"."+t.slice(1);else if(u=="0")return u;if(n!=null)if((o=!(n>=2&&n<65))||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};t.toNumber=t.toN=function(){var n=this;return+n||(n.s?0*n.s:NaN)};t.valueOf=t.toJSON=function(){return this.toS()};typeof module!="undefined"&&module.exports?module.exports=i:typeof define=="function"&&define.amd?define(function(){return i}):n.BigNumber=i})(this) \ No newline at end of file diff --git a/js/decimal.min.js b/js/decimal.min.js new file mode 100644 index 0000000..2e33ab4 --- /dev/null +++ b/js/decimal.min.js @@ -0,0 +1,2 @@ +/*! decimal.js v4.0.1 https://github.com/MikeMcl/decimal.js/LICENCE */ +(function(n){"use strict";function l(n){for(var t,e,f=1,r=n.length,u=n[0]+"";f=10;e/=10,o++);return e=t-o,e<0?(e+=i,s=0):(s=Math.ceil((e+1)/i),e%=i),o=h(10,i-e),f=n[s]%o|0,u==null?e<3?(e==0?f=f/100|0:e==1&&(f=f/10|0),c=r<4&&f==99999||r>3&&f==49999||f==5e4||f==0):c=(r<4&&f+1==o||r>3&&f+1==o/2)&&(n[s+1]/o/100|0)==h(10,e-2)-1||(f==o/2||f==0)&&(n[s+1]/o/100|0)==0:e<4?(e==0?f=f/1e3|0:e==1?f=f/100|0:e==2&&(f=f/10|0),c=(u||r<4)&&f==9999||!u&&r>3&&f==4999):c=((u||r<4)&&f+1==o||!u&&r>3&&f+1==o/2)&&(n[s+1]/o/1e3|0)==h(10,e-3)-1,c}function k(n,t,i){var r=n.constructor;return t==null||((c=t<0||t>8)||t!==0&&(r.errors?parseInt:parseFloat)(t)!=t)&&!f(r,"rounding mode",t,i,0)?r.rounding:t|0}function d(n,t,i,r){var u=n.constructor;return!(c=t<(r||0)||t>=et+1)&&(t===0||(u.errors?parseInt:parseFloat)(t)==t)||f(u,"argument",t,i,0)}function rt(n,t){var c,v,k,a,i,f,o,y=0,d=0,p=0,u=n.constructor,w=u.ONE,nt=u.rounding,b=u.precision;if(!n.c||!n.c[0]||n.e>17)return new u(n.c?n.c[0]?n.s<0?0:1/0:w:n.s?n.s<0?0:n:NaN);for(t==null?(e=!1,i=b):i=t,o=new u(.03125);n.e>-2;)n=n.times(o),p+=5;for(v=Math.log(h(2,p))/Math.LN10*2+5|0,i+=v,c=a=f=new u(w),u.precision=i;;){if(a=r(a.times(n),i,1),c=c.times(++d),o=f.plus(s(a,c,i,1)),l(o.c).slice(0,i)===l(f.c).slice(0,i)){for(k=p;k--;)f=r(f.times(f),i,1);if(t==null)if(y<3&&g(f.c,i-v,nt,y))u.precision=i+=10,c=a=o=new u(w),d=0,y++;else return r(f,u.precision=b,nt,e=!0);else return u.precision=b,f}f=o}}function nt(n,t,i,u){var f,o,s=n.constructor,e=(n=new s(n)).e;if(t==null?i=0:(r(n,++t,i),i=u?t:t+n.e-e),e=n.e,f=l(n.c),u==1||u==2&&(t<=e||e<=s.toExpNeg)){for(;f.length1&&(f=f.charAt(0)+"."+f.slice(1));f+=(e<0?"e":"e+")+e}else{if(u=f.length,e<0){for(o=i-u;++e;f="0"+f);f="0."+f}else if(++e>u){for(o=i-e,e-=u;e--;f+="0");o>0&&(f+=".")}else o=i-u,e0&&(f+=".");if(o>0)for(;o--;f+="0");}return n.s<0&&n.c[0]?"-"+f:f}function ot(n){var t=n.length-1,r=t*i+1;if(t=n[t]){for(;t%10==0;t/=10,r--);for(t=n[0];t>=10;t/=10,r++);}return r}function f(n,t,i,r,f){if(n.errors){var e=new Error((r||["new Decimal","cmp","div","eq","gt","gte","lt","lte","minus","mod","plus","times","toFraction","pow","random","log","sqrt","toNearest","divToInt"][u?u<0?-u:u:1/u<0?1:0])+"() "+(["number type has more than 15 significant digits","LN10 out of digits"][t]||t+([c?" out of range":" not an integer"," not a boolean or binary digit"][f]||""))+": "+i);e.name="Decimal Error";c=u=0;throw e;}}function st(n,t,i){var r=new n(n.ONE);for(e=!1;;){if(i&1&&(r=r.times(t)),i>>=1,!i)break;t=t.times(t)}return e=!0,r}function p(n,t){var c,a,d,w,b,et,u,h,nt,rt,ut,ot=1,tt=10,i=n,v=i.c,o=i.constructor,it=o.ONE,ft=o.rounding,k=o.precision;if(i.s<0||!v||!v[0]||!i.e&&v[0]==1&&v.length==1)return new o(v&&!v[0]?-1/0:i.s!=1?NaN:v?0:i);if(t==null?(e=!1,u=k):u=t,o.precision=u+=tt,c=l(v),a=c.charAt(0),Math.abs(w=i.e)<15e14){while(a<7&&a!=1||a==1&&c.charAt(1)>3)i=i.times(n),c=l(i.c),a=c.charAt(0),ot++;w=i.e;a>1?(i=new o("0."+c),w++):i=new o(a+"."+c.slice(1))}else return i=new o(a+"."+c.slice(1)),u+2>y.length&&f(o,1,u+2,"ln"),i=p(i,u-tt).plus(new o(y.slice(0,u+2)).times(w+"")),o.precision=k,t==null?r(i,k,ft,e=!0):i;for(rt=i,h=b=i=s(i.minus(it),i.plus(it),u,1),ut=r(i.times(i),u,1),d=3;;){if(b=r(b.times(ut),u,1),nt=h.plus(s(b,new o(d),u,1)),l(nt.c).slice(0,u)===l(h.c).slice(0,u))if(h=h.times(2),w!==0&&(u+2>y.length&&f(o,1,u+2,"ln"),h=h.plus(new o(y.slice(0,u+2)).times(w+""))),h=s(h,new o(ot),u,1),t==null)if(g(h.c,u-tt,ft,et))o.precision=u+=tt,nt=b=i=s(rt.minus(it),rt.plus(it),u,1),ut=r(i.times(i),u,1),d=et=1;else return r(h,o.precision=k,ft,e=!0);else return o.precision=k,h;h=nt;d+=2}}function r(n,t,r,u){var y,c,s,l,p,w,f,a,b=n.constructor;n:if(t!=null){if(!(f=n.c))return n;for(y=1,l=f[0];l>=10;l/=10,y++);if(c=t-y,c<0)c+=i,s=t,p=f[a=0],w=p/h(10,y-s-1)%10|0;else if(a=Math.ceil((c+1)/i),a>=f.length)if(u){for(;f.length<=a;f.push(0));p=w=0;y=1;c%=i;s=c-i+1}else break n;else{for(p=l=f[a],y=1;l>=10;l/=10,y++);c%=i;s=c-i+y;w=s<0?0:o(p/h(10,y-s-1)%10)}if(u=u||t<0||f[a+1]!=null||(s<0?p:p%h(10,y-s-1)),u=r<4?(w||u)&&(r==0||r==(n.s<0?3:2)):w>5||w==5&&(r==4||u||r==6&&(c>0?s>0?p/h(10,y-s):0:f[a-1])%10&1||r==(n.s<0?8:7)),t<1||!f[0])return f.length=0,u?(t-=n.e+1,f[0]=h(10,t%i),n.e=-t||0):f[0]=n.e=0,n;if(c==0?(f.length=a,l=1,a--):(f.length=a+1,l=h(10,i-c),f[a]=s>0?(p/h(10,y-s)%h(10,s)|0)*l:0),u)for(;;)if(a==0){for(c=1,s=f[0];s>=10;s/=10,c++);for(s=f[0]+=l,l=1;s>=10;s/=10,l++);c!=l&&(n.e++,f[0]==v&&(f[0]=1));break}else{if(f[a]+=l,f[a]!=v)break;f[a--]=0;l=1}for(c=f.length;f[--c]===0;f.pop());}return e&&(n.e>b.maxE?n.c=n.e=null:n.eo^r?1:-1;for(i=-1,h=(e=f.length)<(o=s.length)?e:o;++is[i]^r?1:-1;return e==o?0:e>o^r?1:-1},t.decimalPlaces=t.dp=function(){var r,n,t=null;if(r=this.c){if(t=((n=r.length-1)-o(this.e/i))*i,n=r[n])for(;n%10==0;n/=10,t--);t<0&&(t=0)}return t},t.dividedBy=t.div=function(n,t){return u=2,s(this,new this.constructor(n,t))},t.dividedToIntegerBy=t.divToInt=function(n,t){var f=this,i=f.constructor;return u=18,r(s(f,new i(n,t),0,1,1),i.precision,i.rounding)},t.equals=t.eq=function(n,t){return u=3,this.cmp(n,t)===0},t.exponential=t.exp=function(){return rt(this)},t.floor=function(){return r(new this.constructor(this),this.e+1,3)},t.greaterThan=t.gt=function(n,t){return u=4,this.cmp(n,t)>0},t.greaterThanOrEqualTo=t.gte=function(n,t){return u=5,t=this.cmp(n,t),t==1||t===0},t.isFinite=function(){return!!this.c},t.isInteger=t.isInt=function(){return!!this.c&&o(this.e/i)>this.c.length-2},t.isNaN=function(){return!this.s},t.isNegative=t.isNeg=function(){return this.s<0},t.isZero=function(){return!!this.c&&this.c[0]==0},t.lessThan=t.lt=function(n,t){return u=6,this.cmp(n,t)<0},t.lessThanOrEqualTo=t.lte=function(n,t){return u=7,t=this.cmp(n,t),t==-1||t===0},t.logarithm=t.log=function(n,t){var k,i,b,o,it,d,h,a,v,w=this,c=w.constructor,nt=c.precision,tt=c.rounding;if(n==null)n=new c(10),k=!0;else{if(u=15,n=new c(n,t),i=n.c,n.s<0||!i||!i[0]||!n.e&&i[0]==1&&i.length==1)return new c(NaN);k=n.eq(10)}if(i=w.c,w.s<0||!i||!i[0]||!w.e&&i[0]==1&&i.length==1)return new c(i&&!i[0]?-1/0:w.s!=1?NaN:i?0:1/0);if(it=k&&(o=i[0],i.length>1||o!=1&&o!=10&&o!=100&&o!=1e3&&o!=1e4&&o!=1e5&&o!=1e6),e=!1,h=nt+5,a=h+10,d=p(w,h),k?(a>y.length&&f(c,1,a,"log"),b=new c(y.slice(0,a))):b=p(n,h),v=s(d,b,h,1),g(v.c,o=nt,tt))do if(h+=10,d=p(w,h),k?(a=h+10,a>y.length&&f(c,1,a,"log"),b=new c(y.slice(0,a))):b=p(n,h),v=s(d,b,h,1),!it){+l(v.c).slice(o+1,o+15)+1==1e14&&(v=r(v,nt+1,0));break}while(g(v.c,o+=10,tt));return e=!0,r(v,nt,tt)},t.minus=function(n,t){var a,c,p,k,l=this,w=l.constructor,h=l.s;if(u=8,n=new w(n,t),t=n.s,!h||!t)return new w(NaN);if(h!=t)return n.s=-t,l.plus(n);var f=l.c,s=n.c,b=o(n.e/i),y=o(l.e/i),g=w.precision,d=w.rounding;if(!y||!b){if(!f||!s)return f?(n.s=-t,n):new w(s?l:NaN);if(!f[0]||!s[0])return l=s[0]?(n.s=-t,n):new w(f[0]?l:d==3?-0:0),e?r(l,g,d):l}if(f=f.slice(),c=f.length,h=y-b){for((k=h<0)?(h=-h,a=f,c=s.length):(b=y,a=s),(y=Math.ceil(g/i))>c&&(c=y),h>(c+=2)&&(h=c,a.length=1),a.reverse(),t=h;t--;a.push(0));a.reverse()}else for((k=c<(p=s.length))&&(p=c),h=t=0;t0)for(;t--;f[p++]=0);for(y=v-1,t=s.length;t>h;){if(f[--t]=10;t/=10,h++);return n.e=h+b*i-1,e?r(n,g,d):n},t.modulo=t.mod=function(n,t){var h,f,i=this,o=i.constructor,c=o.modulo;return(u=9,n=new o(n,t),t=n.s,h=!i.c||!t||n.c&&!n.c[0],h||!n.c||i.c&&!i.c[0])?h?new o(NaN):r(new o(i),o.precision,o.rounding):(e=!1,c==9?(n.s=1,f=s(i,n,0,3,1),n.s=t,f.s*=t):f=s(i,n,0,c,1),f=f.times(n),e=!0,i.minus(f))},t.naturalLogarithm=t.ln=function(){return p(this)},t.negated=t.neg=function(){var n=new this.constructor(this);return n.s=-n.s||null,r(n)},t.plus=function(n,t){var l,c=this,y=c.constructor,f=c.s;if(u=10,n=new y(n,t),t=n.s,!f||!t)return new y(NaN);if(f!=t)return n.s=-t,c.minus(n);var s=c.c,h=n.c,p=o(n.e/i),a=o(c.e/i),w=y.precision,b=y.rounding;if(!a||!p){if(!s||!h)return new y(f/0);if(!s[0]||!h[0])return c=h[0]?n:new y(s[0]?c:f*0),e?r(c,w,b):c}if(s=s.slice(),f=a-p){for(f<0?(f=-f,l=s,t=h.length):(p=a,l=h,t=s.length),(a=Math.ceil(w/i))>t&&(t=a),f>++t&&(f=t,l.length=1),l.reverse();f--;l.push(0));l.reverse()}for(s.length-h.length<0&&(l=h,h=s,s=l),f=h.length,t=0,a=v;f;s[f]%=a)t=(s[--f]=s[f]+h[f]+t)/a|0;for(t&&(s.unshift(t),++p),f=s.length;s[--f]==0;s.pop());for(n.c=s,f=1,t=s[0];t>=10;t/=10,f++);return n.e=f+p*i-1,e?r(n,w,b):n},t.precision=t.sd=function(n){var t=null,i=this;return n!=t&&n!==!!n&&n!==1&&n!==0&&f(i.constructor,"argument",n,"precision",1),i.c&&(t=ot(i.c),n&&i.e+1>t&&(t=i.e+1)),t},t.round=function(){var n=this,t=n.constructor;return r(new t(n),n.e+1,t.rounding)},t.squareRoot=t.sqrt=function(){var p,n,c,i,y,h,f=this,a=f.c,u=f.s,t=f.e,v=f.constructor,w=new v(.5);if(u!==1||!a||!a[0])return new v(!u||u<0&&(!a||a[0])?NaN:a?f:1/0);for(e=!1,u=Math.sqrt(+f),u==0||u==1/0?(n=l(a),(n.length+t)%2==0&&(n+="0"),u=Math.sqrt(n),t=o((t+1)/2)-(t<0||t%2),u==1/0?n="1e"+t:(n=u.toExponential(),n=n.slice(0,n.indexOf("e")+1)+t),i=new v(n)):i=new v(u.toString()),c=(t=v.precision)+3;;)if(h=i,i=w.times(h.plus(s(f,h,c+2,1))),l(h.c).slice(0,c)===(n=l(i.c)).slice(0,c))if(n=n.slice(c-3,c+1),n!="9999"&&(y||n!="4999")){+n&&(+n.slice(1)||n.charAt(0)!="5")||(r(i,t+1,1),p=!i.times(i).eq(f));break}else{if(!y&&(r(h,t+1,0),h.times(h).eq(f))){i=h;break}c+=4;y=1}return e=!0,r(i,t,v.rounding,p)},t.times=function(n,t){var f,w,y=this,p=y.constructor,c=y.c,l=(u=11,n=new p(n,t),n.c),a=o(y.e/i),s=o(n.e/i),h=y.s;if(t=n.s,n.s=h==t?1:-1,!a&&(!c||!c[0])||!s&&(!l||!l[0]))return new p(!h||!t||c&&!c[0]&&!l||l&&!l[0]&&!c?NaN:!c||!l?n.s/0:n.s*0);for(w=a+s,h=c.length,t=l.length,h-1;a--){for(t=0,s=h+a;s>a;)t=f[s]+l[a]*c[s-a-1]+t,f[s--]=t%v|0,t=t/v|0;f[s]=(f[s]+t)%v|0}for(t?++w:f[0]||f.shift(),s=f.length;!f[--s];f.pop());for(n.c=f,h=1,t=f[0];t>=10;t/=10,h++);return n.e=h+w*i-1,e?r(n,p.precision,p.rounding):n},t.toDecimalPlaces=t.toDP=function(n,t){var i=this;return i=new i.constructor(i),n==null||!d(i,n,"toDP")?i:r(i,(n|0)+i.e+1,k(i,t,"toDP"))},t.toExponential=function(n,t){var i=this;return i.c?nt(i,n!=null&&d(i,n,"toExponential")?n|0:null,n!=null&&k(i,t,"toExponential"),1):i.toString()},t.toFixed=function(n,t){var i,r=this,u=r.constructor,f=u.toExpNeg,e=u.toExpPos;return n!=null&&(n=d(r,n,i="toFixed")?r.e+(n|0):null,t=k(r,t,i)),u.toExpNeg=-(u.toExpPos=1/0),n!=null&&r.c?(i=nt(r,n,t),r.s<0&&r.c&&(r.c[0]?i.indexOf("-")<0&&(i="-"+i):i=i.replace("-",""))):i=r.toString(),u.toExpNeg=f,u.toExpPos=e,i},t.toFormat=function(n,t){var o=this;if(!o.c)return o.toString();var r,l=o.s<0,f=o.constructor.format,a=f.groupSeparator,u=+f.groupSize,e=+f.secondaryGroupSize,v=o.toFixed(n,t).split("."),i=v[0],c=v[1],s=l?i.slice(1):i,h=s.length;if(e&&(h-=(r=u,u=e,e=r)),u>0&&h>0){for(r=h%u||u,i=s.substr(0,r);r0&&(i+=a+s.slice(r));l&&(i="-"+i)}return c?i+f.decimalSeparator+((e=+f.fractionGroupSize)?c.replace(new RegExp("\\d{"+e+"}\\B","g"),"$&"+f.fractionGroupSeparator):c):i},t.toFraction=function(n){var v,r,d,it,a,y,g,nt,b=this,t=b.constructor,p=v=new t(t.ONE),w=y=new t(0),tt=b.c,k=new t(w);if(!tt)return b.toString();for(d=k.e=ot(tt)-b.e-1,k.c[0]=h(10,(g=d%i)<0?i+g:g),(n==null||(!(u=12,a=new t(n)).s||(c=a.cmp(p)<0||!a.c)||t.errors&&o(a.e/i)0)&&(n=d>0?k:p),e=!1,a=new t(l(tt)),g=t.precision,t.precision=d=tt.length*i*2;;){if(nt=s(a,k,0,1,1),r=v.plus(nt.times(w)),r.cmp(n)==1)break;v=w;w=r;p=y.plus(nt.times(r=p));y=r;k=a.minus(nt.times(r=k));a=r}return r=s(n.minus(v),w,0,1,1),y=y.plus(r.times(p)),v=v.plus(r.times(w)),y.s=p.s=b.s,it=s(p,w,d,1).minus(b).abs().cmp(s(y,v,d,1).minus(b).abs())<1?[p+"",w+""]:[y+"",v+""],e=!0,t.precision=g,it},t.toNearest=function(n,t){var i=this,f=i.constructor;return i=new f(i),n==null?(n=new f(f.ONE),t=f.rounding):(u=17,n=new f(n),t=k(i,t,"toNearest")),n.c?i.c&&(n.c[0]?(e=!1,i=s(i,n,0,t<4?[4,5,7,8][t]:t,1).times(n),e=!0,r(i)):i.c=[i.e=0]):i.s&&(n.s&&(n.s=i.s),i=n),i},t.toNumber=function(){var n=this;return+n||(n.s?0*n.s:NaN)},t.toPower=t.pow=function(n,t){var nt,a,b,s,f=this,c=f.constructor,y=f.s,w=+(u=13,n=new c(n,t)),k=w<0?-w:w,v=c.precision,d=c.rounding;if(!f.c||!n.c||(b=!f.c[0])||!n.c[0])return new c(h(b?y*0:+f,w));if(f=new c(f),nt=f.c.length,!f.e&&f.c[0]==f.s&&nt==1)return f;if(t=n.c.length-1,n.e||n.c[0]!=n.s||t)if(a=o(n.e/i),b=a>=t,!b&&y<0)s=new c(NaN);else{if(b&&nt*i*kc.maxE+1||a0?y/0:0);e=!1;c.rounding=f.s=1;k=Math.min(12,(a+"").length);s=rt(n.times(p(f,v+k)),v);s=r(s,v+5,1);g(s.c,v,d)&&(a=v+10,s=r(rt(n.times(p(f,a+k)),a),a+5,1),+l(s.c).slice(v+1,v+15)+1==1e14&&(s=r(s,v+1,0)));s.s=y;e=!0;c.rounding=d}s=r(s,v,d)}else s=r(f,v,d);return s},t.toPrecision=function(n,t){var i=this;return n!=null&&d(i,n,"toPrecision",1)&&i.c?nt(i,--n|0,k(i,t,"toPrecision"),2):i.toString()},t.toSignificantDigits=t.toSD=function(n,t){var i=this,u=i.constructor;return i=new u(i),n==null||!d(i,n,"toSD",1)?r(i,u.precision,u.rounding):r(i,n|0,k(i,t,"toSD"))},t.toString=function(n){var e,t,o,r=this,u=r.constructor,i=r.e;if(i===null)t=r.s?"Infinity":"NaN";else{if(n===e&&(i<=u.toExpNeg||i>=u.toExpPos))return nt(r,null,u.rounding,1);if(t=l(r.c),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 i1)t=e+"."+t.slice(1);else if(e=="0")return e;if(n!=null)if((c=!(n>=2&&n<65))||n!=(n|0)&&u.errors)f(u,"base",n,"toString",0);else if(t=tt(u,t,n|0,10,r.s),t=="0")return t}return r.s<0?"-"+t:t},t.truncated=t.trunc=function(){return r(new this.constructor(this),this.e+1,1)},t.valueOf=t.toJSON=function(){return this.toString()},tt=function(){function n(n,t,i){for(var u,r=[0],f,e=0,o=n.length;ei-1&&(r[u+1]==null&&(r[u+1]=0),r[u+1]+=r[u]/i|0,r[u]%=i)}return r.reverse()}return function(t,i,r,u,f){var h,a,p,c,e,y,o=i.indexOf("."),l=t.precision,v=t.rounding;for(u<37&&(i=i.toLowerCase()),o>=0&&(i=i.replace(".",""),y=new t(u),c=st(t,y,i.length-o),y.c=n(c.toFixed(),10,r),y.e=y.c.length),e=n(i,u,r),h=a=e.length;e[--a]==0;e.pop());if(!e[0])return"0";if(o<0?h--:(c.c=e,c.e=h,c.s=f,c=s(c,y,l,v,0,r),e=c.c,p=c.r,h=c.e),o=e[l],a=r/2,p=p||e[l+1]!=null,v<4?(o!=null||p)&&(v==0||v==(c.s<0?3:2)):o>a||o==a&&(v==4||p||v==6&&e[l-1]&1||v==(c.s<0?8:7)))for(e.length=l,--r;++e[--l]>r;)e[l]=0,l||(++h,e.unshift(1));else e.length=l;for(a=e.length;!e[--a];);for(o=0,i="";o<=a;i+=it.charAt(e[o++]));if(h<0){for(;++h;i="0"+i);i="0."+i}else if(o=i.length,++h>o)for(h-=o;h--;i+="0");else hr?1:-1;else for(u=f=0;ut[u]?1:-1;break}return f}function u(n,t,i,r){for(var u=0;i--;)n[i]-=u,u=n[i]1;n.shift());}return function(f,e,s,h,c,l){var nt,et,w,rt,ot,y,tt,ft,it,ut,p,b,ht,vt,ct,st,yt,g,lt,at=f.constructor,d=f.s==e.s?1:-1,k=f.c,a=e.c;if(!k||!k[0]||!a||!a[0])return new at(!f.s||!e.s||(k?a&&k[0]==a[0]:!a)?NaN:k&&k[0]==0||!a?d*0:d/0);for(l?(rt=1,et=f.e-e.e):(l=v,rt=i,et=o(f.e/rt)-o(e.e/rt)),g=a.length,st=k.length,it=new at(d),ut=it.c=[],w=0;a[w]==(k[w]||0);w++);if(a[w]>(k[w]||0)&&et--,s==null?(d=s=at.precision,h=at.rounding):d=c?s+(f.e-e.e)+1:s,d<0)ut.push(1),ot=!0;else{if(d=d/rt+2|0,w=0,g==1){for(y=0,a=a[0],d++;(w1&&(a=n(a,y,l),k=n(k,y,l),g=a.length,st=k.length),ct=g,p=k.slice(0,g),b=p.length;b=l/2&&yt++;do y=0,nt=t(a,p,g,b),nt<0?(ht=p[0],g!=b&&(ht=ht*l+(p[1]||0)),y=ht/yt|0,y>1?(y>=l&&(y=l-1),tt=n(a,y,l),ft=tt.length,b=p.length,nt=t(tt,p,ft,b),nt==1&&(y--,u(tt,g=10;d/=10,w++);it.e=w+et*rt-1;r(it,c?s+it.e+1:s,h,ot)}return it}}(),w=function(){function l(n){var i,e,t,r=this,s="config",h=r.errors?parseInt:parseFloat;return n==e||typeof n!="object"&&!f(r,"object expected",n,s)?r:((t=n[i="precision"])!=e&&((c=t<1||t>et)||h(t)!=t?f(r,i,t,s,0):r[i]=t|0),(t=n[i="rounding"])!=e&&((c=t<0||t>8)||h(t)!=t?f(r,i,t,s,0):r[i]=t|0),(t=n[i="toExpNeg"])!=e&&((c=t<-b||t>0)||h(t)!=t?f(r,i,t,s,0):r[i]=o(t)),(t=n[i="toExpPos"])!=e&&((c=t<0||t>b)||h(t)!=t?f(r,i,t,s,0):r[i]=o(t)),(t=n[i="minE"])!=e&&((c=t<-b||t>0)||h(t)!=t?f(r,i,t,s,0):r[i]=o(t)),(t=n[i="maxE"])!=e&&((c=t<0||t>b)||h(t)!=t?f(r,i,t,s,0):r[i]=o(t)),(t=n[i="errors"])!=e&&(t===!!t||t===1||t===0?(c=u=0,r[i]=!!t):f(r,i,t,s,1)),(t=n[i="crypto"])!=e&&(t===!!t||t===1||t===0?r[i]=!!(t&&a&&typeof a=="object"):f(r,i,t,s,1)),(t=n[i="modulo"])!=e&&((c=t<0||t>9)||h(t)!=t?f(r,i,t,s,0):r[i]=t|0),(n=n[i="format"])!=e&&(typeof n=="object"?r[i]=n:f(r,"format object expected",n,s)),r)}function v(n){return new this(n).exp()}function y(n){return new this(n).ln()}function p(n,t){return new this(n).log(t)}function n(n,t,i){var r,u,f=0;for(ft.call(t[0])=="[object Array]"&&(t=t[0]),r=new n(t[0]);++f=429e7?o[t]=a.getRandomValues(new Uint32Array(1))[0]:e[t++]=u%1e7;else if(a&&a.randomBytes){for(o=a.randomBytes(r*=4);t=214e7?a.randomBytes(4).copy(o,t):(e.push(u%1e7),t+=4);t=r/4}else f(s,"crypto unavailable",a,"random");if(!t)for(;t=10;)u/=10,t++;t=2&&l<65))?(f(o,"base",l,0,0),w=n.test(h)):(b="["+it.slice(0,l=l|0)+"]+",h=h.replace(/\.$/,"").replace(/^\./,"0."),(w=new RegExp("^"+b+"(?:\\."+b+")?$",l<37?"i":"").test(h))?(y&&(h.replace(/^0\.0*|\./,"").length>15&&f(o,0,p),y=!y),h=tt(o,h,10,l,s.s)):h!="Infinity"&&h!="NaN"&&(f(o,"not a base "+l+" number",p),h="NaN")):w=n.test(h),!w)return s.c=s.e=null,h!="Infinity"&&(h!="NaN"&&f(o,"not a number",p),s.s=null),u=0,s}for((v=h.indexOf("."))>-1&&(h=h.replace(".","")),(a=h.search(/e/i))>0?(v<0&&(v=a),v+=+h.slice(a+1),h=h.substring(0,a)):v<0&&(v=h.length),a=0;h.charCodeAt(a)===48;a++);for(l=h.length;h.charCodeAt(--l)===48;);if(h=h.slice(a,l+1),h){if(l=h.length,y&&l>15&&f(o,0,p),s.e=v=v-a-1,s.c=[],a=(v+1)%i,v<0&&(a+=i),ao.maxE?s.c=s.e=null:s.e= 0){ + if(number.comparedTo(Infinity) == 0){ + return "∞"; + } + if(number.comparedTo(1e21) >= 0){ // Very ugly way to extract the mantisa and exponent from an exponential string - var exponential = number.toExponential(13).split("e"); - var exponent = new BigNumber(exponential[1].split("+")[1]); - //return $scope.currency.toPrecision(15); + var exponential = number.toString().split("e"); + var exponent = new Decimal(exponential[1].split("+")[1]); // And it is displayed in with superscript return exponential[0]+" x 10"+prettifyNumber(exponent)+""; }