pyret-npm 0.0.66 → 0.0.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pyret-npm",
3
- "version": "0.0.66",
3
+ "version": "0.0.68",
4
4
  "description": "The CLI for the Pyret programming language",
5
5
  "files": [
6
6
  "pyret.js",
@@ -39248,31 +39248,7 @@ define("pyret-base/js/js-numbers", function() {
39248
39248
 
39249
39249
  // fromFixnum: fixnum -> pyretnum
39250
39250
  var fromFixnum = function(x, errbacks) {
39251
- if (!isFinite(x)) {
39252
- return Roughnum.makeInstance(x, errbacks);
39253
- }
39254
- var nf = Math.floor(x);
39255
- if (nf === x) {
39256
- if (isOverflow(nf)) {
39257
- return makeBignum(expandExponent(x+''));
39258
- } else {
39259
- return nf;
39260
- }
39261
- } else {
39262
- // used to return float, now rational
39263
- var stringRep = x.toString();
39264
- var match = stringRep.match(/^(.*)\.(.*)$/);
39265
- if (match) {
39266
- var afterDecimal = parseInt(match[2]);
39267
- var factorToInt = Math.pow(10, match[2].length);
39268
- var extraFactor = _integerGcd(factorToInt, afterDecimal);
39269
- var multFactor = factorToInt / extraFactor;
39270
- return Rational.makeInstance(Math.round(x*multFactor), Math.round(factorToInt/extraFactor), errbacks);
39271
- } else {
39272
- return Rational.makeInstance(x, 1, errbacks);
39273
- }
39274
-
39275
- }
39251
+ return fromString(String(x), errbacks);
39276
39252
  };
39277
39253
 
39278
39254
  var expandExponent = function(s) {
@@ -39901,6 +39877,8 @@ define("pyret-base/js/js-numbers", function() {
39901
39877
  // NB: all of these trig-gy generic functions should now return roughnum rather than float
39902
39878
  // (except for an arg of 0, etc)
39903
39879
 
39880
+ var ln10 = Math.log(10)
39881
+
39904
39882
  // log: pyretnum -> pyretnum
39905
39883
  var log = function(n, errbacks) {
39906
39884
  if ( eqv(n, 1, errbacks) ) {
@@ -39912,7 +39890,35 @@ define("pyret-base/js/js-numbers", function() {
39912
39890
  if (typeof(n) === 'number') {
39913
39891
  return Roughnum.makeInstance(Math.log(n), errbacks);
39914
39892
  }
39915
- return n.log(errbacks);
39893
+ var nFix = n.toFixnum();
39894
+ if (typeof(nFix) === 'number' && nFix !== Infinity) {
39895
+ return Roughnum.makeInstance(Math.log(nFix), errbacks);
39896
+ }
39897
+ // at this point, n must be a very large positive number;
39898
+ // n > 1e308, i.e, has at least 308 digits;
39899
+ // we can safely ignore its fractional part;
39900
+ var nStr = n.round(errbacks).toString();
39901
+ var nLen = nStr.length;
39902
+ // we furthermore need only the integer part's first few digits
39903
+ // although we must remember the number of digits ignored;
39904
+ var firstFewLen = 308; // has to be <= 308
39905
+ // say integer N = yyy...yyyxxx...xxx
39906
+ // where the number of x's is nx;
39907
+ // So N ~= yyy...yyy * 10^nx
39908
+ // We'll first find the common (base 10) log of N
39909
+ // log10(N) ~= log10(yyy...yyy * 10^nx)
39910
+ // = log10(yyy...yyy) + nx
39911
+ // Now to convert this to the natural log
39912
+ // ln(N) = log10(N) / log10(e)
39913
+ // = log10(N) * ln(10)
39914
+ // ~= [log10(yyy...yyy) + nx] * ln(10)
39915
+ // = log10(yyy...yyy) * ln(10) + nx * ln(10)
39916
+ // = ln(yyy...yyy) + nx * ln(10)
39917
+ // JS gives us ln(yyy...yyy) and ln(10) so we have a good
39918
+ // approximation for ln(N)
39919
+ var nFirstFew = parseInt(nStr.substring(0, firstFewLen));
39920
+ var nLog = Math.log(nFirstFew) + (nLen - firstFewLen) * ln10;
39921
+ return Roughnum.makeInstance(nLog, errbacks);
39916
39922
  };
39917
39923
 
39918
39924
  // tan: pyretnum -> pyretnum
@@ -41121,7 +41127,6 @@ define("pyret-base/js/js-numbers", function() {
41121
41127
 
41122
41128
  var roughnumRatRegexp = new RegExp("^~([+-]?\\d+)/(\\d+)$");
41123
41129
 
41124
-
41125
41130
  var scientificPattern = new RegExp("^([+-]?\\d*\\.?\\d*)[Ee]([+]?\\d+)$");
41126
41131
 
41127
41132
  // fromString: string -> (pyretnum | false)
@@ -41977,8 +41982,13 @@ define("pyret-base/js/js-numbers", function() {
41977
41982
  function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
41978
41983
 
41979
41984
  // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
41980
- function bnpExp(e,z) {
41981
- if(e > 0xffffffff || e < 1) return BigInteger.ONE;
41985
+ function bnpExp(e, z, errbacks) {
41986
+ if (greaterThan(e, 0xffffffff, errbacks)) {
41987
+ errbacks.throwDomainError('expt: exponent ' + e + ' too large');
41988
+ }
41989
+ if (lessThan(e, 1, errbacks)) {
41990
+ return BigInteger.ONE;
41991
+ }
41982
41992
  var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
41983
41993
  g.copyTo(r);
41984
41994
  while(--i >= 0) {
@@ -41990,10 +42000,10 @@ define("pyret-base/js/js-numbers", function() {
41990
42000
  }
41991
42001
 
41992
42002
  // (public) this^e % m, 0 <= e < 2^32
41993
- function bnModPowInt(e,m) {
42003
+ function bnModPowInt(e, m, errbacks) {
41994
42004
  var z;
41995
42005
  if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
41996
- return this.bnpExp(e,z);
42006
+ return this.bnpExp(e, z, errbacks);
41997
42007
  }
41998
42008
 
41999
42009
  // protected
@@ -42362,7 +42372,9 @@ define("pyret-base/js/js-numbers", function() {
42362
42372
  NullExp.prototype.sqrTo = nSqrTo;
42363
42373
 
42364
42374
  // (public) this^e
42365
- function bnPow(e) { return this.bnpExp(e,new NullExp()); }
42375
+ function bnPow(e, errbacks) {
42376
+ return this.bnpExp(e,new NullExp(), errbacks);
42377
+ }
42366
42378
 
42367
42379
  // (protected) r = lower n words of "this * a", a.t <= n
42368
42380
  // "this" should be the larger one if appropriate.
@@ -42862,48 +42874,48 @@ define("pyret-base/js/js-numbers", function() {
42862
42874
 
42863
42875
  // round: -> pyretnum
42864
42876
  // Round to the nearest integer.
42865
- BigInteger.prototype.round = function(n, errbacks) {
42877
+ BigInteger.prototype.round = function(errbacks) {
42866
42878
  return this;
42867
42879
  };
42868
42880
 
42869
- BigInteger.prototype.roundEven = function(n, errbacks) {
42881
+ BigInteger.prototype.roundEven = function(errbacks) {
42870
42882
  return this;
42871
42883
  };
42872
42884
 
42873
42885
  // log: -> pyretnum
42874
42886
  // Produce the log.
42875
- BigInteger.prototype.log = function(n, errbacks) {
42887
+ BigInteger.prototype.log = function(errbacks) {
42876
42888
  return log(this.toFixnum(), errbacks);
42877
42889
  };
42878
42890
 
42879
42891
  // tan: -> pyretnum
42880
42892
  // Produce the tan.
42881
- BigInteger.prototype.tan = function(n, errbacks) {
42893
+ BigInteger.prototype.tan = function(errbacks) {
42882
42894
  return tan(this.toFixnum(), errbacks);
42883
42895
  };
42884
42896
 
42885
42897
  // atan: -> pyretnum
42886
42898
  // Produce the arc tangent.
42887
- BigInteger.prototype.atan = function(n, errbacks) {
42899
+ BigInteger.prototype.atan = function(errbacks) {
42888
42900
  return atan(this.toFixnum(), errbacks);
42889
42901
  };
42890
42902
 
42891
42903
  // cos: -> pyretnum
42892
42904
  // Produce the cosine.
42893
- BigInteger.prototype.cos = function(n, errbacks) {
42905
+ BigInteger.prototype.cos = function(errbacks) {
42894
42906
  return cos(this.toFixnum(), errbacks);
42895
42907
  };
42896
42908
 
42897
42909
  // sin: -> pyretnum
42898
42910
  // Produce the sine.
42899
- BigInteger.prototype.sin = function(n, errbacks) {
42911
+ BigInteger.prototype.sin = function(errbacks) {
42900
42912
  return sin(this.toFixnum(), errbacks);
42901
42913
  };
42902
42914
 
42903
42915
  // expt: pyretnum -> pyretnum
42904
42916
  // Produce the power to the input.
42905
42917
  BigInteger.prototype.expt = function(n, errbacks) {
42906
- return bnPow.call(this, n);
42918
+ return bnPow.call(this, n, errbacks);
42907
42919
  };
42908
42920
 
42909
42921
  // exp: -> pyretnum
@@ -42917,13 +42929,13 @@ define("pyret-base/js/js-numbers", function() {
42917
42929
 
42918
42930
  // acos: -> pyretnum
42919
42931
  // Produce the arc cosine.
42920
- BigInteger.prototype.acos = function(n, errbacks) {
42932
+ BigInteger.prototype.acos = function(errbacks) {
42921
42933
  return acos(this.toFixnum(), errbacks);
42922
42934
  };
42923
42935
 
42924
42936
  // asin: -> pyretnum
42925
42937
  // Produce the arc sine.
42926
- BigInteger.prototype.asin = function(n, errbacks) {
42938
+ BigInteger.prototype.asin = function(errbacks) {
42927
42939
  return asin(this.toFixnum(), errbacks);
42928
42940
  };
42929
42941
 
@@ -160,31 +160,7 @@ define("pyret-base/js/js-numbers", function() {
160
160
 
161
161
  // fromFixnum: fixnum -> pyretnum
162
162
  var fromFixnum = function(x, errbacks) {
163
- if (!isFinite(x)) {
164
- return Roughnum.makeInstance(x, errbacks);
165
- }
166
- var nf = Math.floor(x);
167
- if (nf === x) {
168
- if (isOverflow(nf)) {
169
- return makeBignum(expandExponent(x+''));
170
- } else {
171
- return nf;
172
- }
173
- } else {
174
- // used to return float, now rational
175
- var stringRep = x.toString();
176
- var match = stringRep.match(/^(.*)\.(.*)$/);
177
- if (match) {
178
- var afterDecimal = parseInt(match[2]);
179
- var factorToInt = Math.pow(10, match[2].length);
180
- var extraFactor = _integerGcd(factorToInt, afterDecimal);
181
- var multFactor = factorToInt / extraFactor;
182
- return Rational.makeInstance(Math.round(x*multFactor), Math.round(factorToInt/extraFactor), errbacks);
183
- } else {
184
- return Rational.makeInstance(x, 1, errbacks);
185
- }
186
-
187
- }
163
+ return fromString(String(x), errbacks);
188
164
  };
189
165
 
190
166
  var expandExponent = function(s) {
@@ -813,6 +789,8 @@ define("pyret-base/js/js-numbers", function() {
813
789
  // NB: all of these trig-gy generic functions should now return roughnum rather than float
814
790
  // (except for an arg of 0, etc)
815
791
 
792
+ var ln10 = Math.log(10)
793
+
816
794
  // log: pyretnum -> pyretnum
817
795
  var log = function(n, errbacks) {
818
796
  if ( eqv(n, 1, errbacks) ) {
@@ -824,7 +802,35 @@ define("pyret-base/js/js-numbers", function() {
824
802
  if (typeof(n) === 'number') {
825
803
  return Roughnum.makeInstance(Math.log(n), errbacks);
826
804
  }
827
- return n.log(errbacks);
805
+ var nFix = n.toFixnum();
806
+ if (typeof(nFix) === 'number' && nFix !== Infinity) {
807
+ return Roughnum.makeInstance(Math.log(nFix), errbacks);
808
+ }
809
+ // at this point, n must be a very large positive number;
810
+ // n > 1e308, i.e, has at least 308 digits;
811
+ // we can safely ignore its fractional part;
812
+ var nStr = n.round(errbacks).toString();
813
+ var nLen = nStr.length;
814
+ // we furthermore need only the integer part's first few digits
815
+ // although we must remember the number of digits ignored;
816
+ var firstFewLen = 308; // has to be <= 308
817
+ // say integer N = yyy...yyyxxx...xxx
818
+ // where the number of x's is nx;
819
+ // So N ~= yyy...yyy * 10^nx
820
+ // We'll first find the common (base 10) log of N
821
+ // log10(N) ~= log10(yyy...yyy * 10^nx)
822
+ // = log10(yyy...yyy) + nx
823
+ // Now to convert this to the natural log
824
+ // ln(N) = log10(N) / log10(e)
825
+ // = log10(N) * ln(10)
826
+ // ~= [log10(yyy...yyy) + nx] * ln(10)
827
+ // = log10(yyy...yyy) * ln(10) + nx * ln(10)
828
+ // = ln(yyy...yyy) + nx * ln(10)
829
+ // JS gives us ln(yyy...yyy) and ln(10) so we have a good
830
+ // approximation for ln(N)
831
+ var nFirstFew = parseInt(nStr.substring(0, firstFewLen));
832
+ var nLog = Math.log(nFirstFew) + (nLen - firstFewLen) * ln10;
833
+ return Roughnum.makeInstance(nLog, errbacks);
828
834
  };
829
835
 
830
836
  // tan: pyretnum -> pyretnum
@@ -2033,7 +2039,6 @@ define("pyret-base/js/js-numbers", function() {
2033
2039
 
2034
2040
  var roughnumRatRegexp = new RegExp("^~([+-]?\\d+)/(\\d+)$");
2035
2041
 
2036
-
2037
2042
  var scientificPattern = new RegExp("^([+-]?\\d*\\.?\\d*)[Ee]([+]?\\d+)$");
2038
2043
 
2039
2044
  // fromString: string -> (pyretnum | false)
@@ -2889,8 +2894,13 @@ define("pyret-base/js/js-numbers", function() {
2889
2894
  function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
2890
2895
 
2891
2896
  // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
2892
- function bnpExp(e,z) {
2893
- if(e > 0xffffffff || e < 1) return BigInteger.ONE;
2897
+ function bnpExp(e, z, errbacks) {
2898
+ if (greaterThan(e, 0xffffffff, errbacks)) {
2899
+ errbacks.throwDomainError('expt: exponent ' + e + ' too large');
2900
+ }
2901
+ if (lessThan(e, 1, errbacks)) {
2902
+ return BigInteger.ONE;
2903
+ }
2894
2904
  var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
2895
2905
  g.copyTo(r);
2896
2906
  while(--i >= 0) {
@@ -2902,10 +2912,10 @@ define("pyret-base/js/js-numbers", function() {
2902
2912
  }
2903
2913
 
2904
2914
  // (public) this^e % m, 0 <= e < 2^32
2905
- function bnModPowInt(e,m) {
2915
+ function bnModPowInt(e, m, errbacks) {
2906
2916
  var z;
2907
2917
  if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
2908
- return this.bnpExp(e,z);
2918
+ return this.bnpExp(e, z, errbacks);
2909
2919
  }
2910
2920
 
2911
2921
  // protected
@@ -3274,7 +3284,9 @@ define("pyret-base/js/js-numbers", function() {
3274
3284
  NullExp.prototype.sqrTo = nSqrTo;
3275
3285
 
3276
3286
  // (public) this^e
3277
- function bnPow(e) { return this.bnpExp(e,new NullExp()); }
3287
+ function bnPow(e, errbacks) {
3288
+ return this.bnpExp(e,new NullExp(), errbacks);
3289
+ }
3278
3290
 
3279
3291
  // (protected) r = lower n words of "this * a", a.t <= n
3280
3292
  // "this" should be the larger one if appropriate.
@@ -3774,48 +3786,48 @@ define("pyret-base/js/js-numbers", function() {
3774
3786
 
3775
3787
  // round: -> pyretnum
3776
3788
  // Round to the nearest integer.
3777
- BigInteger.prototype.round = function(n, errbacks) {
3789
+ BigInteger.prototype.round = function(errbacks) {
3778
3790
  return this;
3779
3791
  };
3780
3792
 
3781
- BigInteger.prototype.roundEven = function(n, errbacks) {
3793
+ BigInteger.prototype.roundEven = function(errbacks) {
3782
3794
  return this;
3783
3795
  };
3784
3796
 
3785
3797
  // log: -> pyretnum
3786
3798
  // Produce the log.
3787
- BigInteger.prototype.log = function(n, errbacks) {
3799
+ BigInteger.prototype.log = function(errbacks) {
3788
3800
  return log(this.toFixnum(), errbacks);
3789
3801
  };
3790
3802
 
3791
3803
  // tan: -> pyretnum
3792
3804
  // Produce the tan.
3793
- BigInteger.prototype.tan = function(n, errbacks) {
3805
+ BigInteger.prototype.tan = function(errbacks) {
3794
3806
  return tan(this.toFixnum(), errbacks);
3795
3807
  };
3796
3808
 
3797
3809
  // atan: -> pyretnum
3798
3810
  // Produce the arc tangent.
3799
- BigInteger.prototype.atan = function(n, errbacks) {
3811
+ BigInteger.prototype.atan = function(errbacks) {
3800
3812
  return atan(this.toFixnum(), errbacks);
3801
3813
  };
3802
3814
 
3803
3815
  // cos: -> pyretnum
3804
3816
  // Produce the cosine.
3805
- BigInteger.prototype.cos = function(n, errbacks) {
3817
+ BigInteger.prototype.cos = function(errbacks) {
3806
3818
  return cos(this.toFixnum(), errbacks);
3807
3819
  };
3808
3820
 
3809
3821
  // sin: -> pyretnum
3810
3822
  // Produce the sine.
3811
- BigInteger.prototype.sin = function(n, errbacks) {
3823
+ BigInteger.prototype.sin = function(errbacks) {
3812
3824
  return sin(this.toFixnum(), errbacks);
3813
3825
  };
3814
3826
 
3815
3827
  // expt: pyretnum -> pyretnum
3816
3828
  // Produce the power to the input.
3817
3829
  BigInteger.prototype.expt = function(n, errbacks) {
3818
- return bnPow.call(this, n);
3830
+ return bnPow.call(this, n, errbacks);
3819
3831
  };
3820
3832
 
3821
3833
  // exp: -> pyretnum
@@ -3829,13 +3841,13 @@ define("pyret-base/js/js-numbers", function() {
3829
3841
 
3830
3842
  // acos: -> pyretnum
3831
3843
  // Produce the arc cosine.
3832
- BigInteger.prototype.acos = function(n, errbacks) {
3844
+ BigInteger.prototype.acos = function(errbacks) {
3833
3845
  return acos(this.toFixnum(), errbacks);
3834
3846
  };
3835
3847
 
3836
3848
  // asin: -> pyretnum
3837
3849
  // Produce the arc sine.
3838
- BigInteger.prototype.asin = function(n, errbacks) {
3850
+ BigInteger.prototype.asin = function(errbacks) {
3839
3851
  return asin(this.toFixnum(), errbacks);
3840
3852
  };
3841
3853
 
@@ -39214,31 +39214,7 @@ define("pyret-base/js/js-numbers", function() {
39214
39214
 
39215
39215
  // fromFixnum: fixnum -> pyretnum
39216
39216
  var fromFixnum = function(x, errbacks) {
39217
- if (!isFinite(x)) {
39218
- return Roughnum.makeInstance(x, errbacks);
39219
- }
39220
- var nf = Math.floor(x);
39221
- if (nf === x) {
39222
- if (isOverflow(nf)) {
39223
- return makeBignum(expandExponent(x+''));
39224
- } else {
39225
- return nf;
39226
- }
39227
- } else {
39228
- // used to return float, now rational
39229
- var stringRep = x.toString();
39230
- var match = stringRep.match(/^(.*)\.(.*)$/);
39231
- if (match) {
39232
- var afterDecimal = parseInt(match[2]);
39233
- var factorToInt = Math.pow(10, match[2].length);
39234
- var extraFactor = _integerGcd(factorToInt, afterDecimal);
39235
- var multFactor = factorToInt / extraFactor;
39236
- return Rational.makeInstance(Math.round(x*multFactor), Math.round(factorToInt/extraFactor), errbacks);
39237
- } else {
39238
- return Rational.makeInstance(x, 1, errbacks);
39239
- }
39240
-
39241
- }
39217
+ return fromString(String(x), errbacks);
39242
39218
  };
39243
39219
 
39244
39220
  var expandExponent = function(s) {
@@ -39867,6 +39843,8 @@ define("pyret-base/js/js-numbers", function() {
39867
39843
  // NB: all of these trig-gy generic functions should now return roughnum rather than float
39868
39844
  // (except for an arg of 0, etc)
39869
39845
 
39846
+ var ln10 = Math.log(10)
39847
+
39870
39848
  // log: pyretnum -> pyretnum
39871
39849
  var log = function(n, errbacks) {
39872
39850
  if ( eqv(n, 1, errbacks) ) {
@@ -39878,7 +39856,35 @@ define("pyret-base/js/js-numbers", function() {
39878
39856
  if (typeof(n) === 'number') {
39879
39857
  return Roughnum.makeInstance(Math.log(n), errbacks);
39880
39858
  }
39881
- return n.log(errbacks);
39859
+ var nFix = n.toFixnum();
39860
+ if (typeof(nFix) === 'number' && nFix !== Infinity) {
39861
+ return Roughnum.makeInstance(Math.log(nFix), errbacks);
39862
+ }
39863
+ // at this point, n must be a very large positive number;
39864
+ // n > 1e308, i.e, has at least 308 digits;
39865
+ // we can safely ignore its fractional part;
39866
+ var nStr = n.round(errbacks).toString();
39867
+ var nLen = nStr.length;
39868
+ // we furthermore need only the integer part's first few digits
39869
+ // although we must remember the number of digits ignored;
39870
+ var firstFewLen = 308; // has to be <= 308
39871
+ // say integer N = yyy...yyyxxx...xxx
39872
+ // where the number of x's is nx;
39873
+ // So N ~= yyy...yyy * 10^nx
39874
+ // We'll first find the common (base 10) log of N
39875
+ // log10(N) ~= log10(yyy...yyy * 10^nx)
39876
+ // = log10(yyy...yyy) + nx
39877
+ // Now to convert this to the natural log
39878
+ // ln(N) = log10(N) / log10(e)
39879
+ // = log10(N) * ln(10)
39880
+ // ~= [log10(yyy...yyy) + nx] * ln(10)
39881
+ // = log10(yyy...yyy) * ln(10) + nx * ln(10)
39882
+ // = ln(yyy...yyy) + nx * ln(10)
39883
+ // JS gives us ln(yyy...yyy) and ln(10) so we have a good
39884
+ // approximation for ln(N)
39885
+ var nFirstFew = parseInt(nStr.substring(0, firstFewLen));
39886
+ var nLog = Math.log(nFirstFew) + (nLen - firstFewLen) * ln10;
39887
+ return Roughnum.makeInstance(nLog, errbacks);
39882
39888
  };
39883
39889
 
39884
39890
  // tan: pyretnum -> pyretnum
@@ -41087,7 +41093,6 @@ define("pyret-base/js/js-numbers", function() {
41087
41093
 
41088
41094
  var roughnumRatRegexp = new RegExp("^~([+-]?\\d+)/(\\d+)$");
41089
41095
 
41090
-
41091
41096
  var scientificPattern = new RegExp("^([+-]?\\d*\\.?\\d*)[Ee]([+]?\\d+)$");
41092
41097
 
41093
41098
  // fromString: string -> (pyretnum | false)
@@ -41943,8 +41948,13 @@ define("pyret-base/js/js-numbers", function() {
41943
41948
  function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
41944
41949
 
41945
41950
  // (protected) this^e, e < 2^32, doing sqr and mul with "r" (HAC 14.79)
41946
- function bnpExp(e,z) {
41947
- if(e > 0xffffffff || e < 1) return BigInteger.ONE;
41951
+ function bnpExp(e, z, errbacks) {
41952
+ if (greaterThan(e, 0xffffffff, errbacks)) {
41953
+ errbacks.throwDomainError('expt: exponent ' + e + ' too large');
41954
+ }
41955
+ if (lessThan(e, 1, errbacks)) {
41956
+ return BigInteger.ONE;
41957
+ }
41948
41958
  var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
41949
41959
  g.copyTo(r);
41950
41960
  while(--i >= 0) {
@@ -41956,10 +41966,10 @@ define("pyret-base/js/js-numbers", function() {
41956
41966
  }
41957
41967
 
41958
41968
  // (public) this^e % m, 0 <= e < 2^32
41959
- function bnModPowInt(e,m) {
41969
+ function bnModPowInt(e, m, errbacks) {
41960
41970
  var z;
41961
41971
  if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
41962
- return this.bnpExp(e,z);
41972
+ return this.bnpExp(e, z, errbacks);
41963
41973
  }
41964
41974
 
41965
41975
  // protected
@@ -42328,7 +42338,9 @@ define("pyret-base/js/js-numbers", function() {
42328
42338
  NullExp.prototype.sqrTo = nSqrTo;
42329
42339
 
42330
42340
  // (public) this^e
42331
- function bnPow(e) { return this.bnpExp(e,new NullExp()); }
42341
+ function bnPow(e, errbacks) {
42342
+ return this.bnpExp(e,new NullExp(), errbacks);
42343
+ }
42332
42344
 
42333
42345
  // (protected) r = lower n words of "this * a", a.t <= n
42334
42346
  // "this" should be the larger one if appropriate.
@@ -42828,48 +42840,48 @@ define("pyret-base/js/js-numbers", function() {
42828
42840
 
42829
42841
  // round: -> pyretnum
42830
42842
  // Round to the nearest integer.
42831
- BigInteger.prototype.round = function(n, errbacks) {
42843
+ BigInteger.prototype.round = function(errbacks) {
42832
42844
  return this;
42833
42845
  };
42834
42846
 
42835
- BigInteger.prototype.roundEven = function(n, errbacks) {
42847
+ BigInteger.prototype.roundEven = function(errbacks) {
42836
42848
  return this;
42837
42849
  };
42838
42850
 
42839
42851
  // log: -> pyretnum
42840
42852
  // Produce the log.
42841
- BigInteger.prototype.log = function(n, errbacks) {
42853
+ BigInteger.prototype.log = function(errbacks) {
42842
42854
  return log(this.toFixnum(), errbacks);
42843
42855
  };
42844
42856
 
42845
42857
  // tan: -> pyretnum
42846
42858
  // Produce the tan.
42847
- BigInteger.prototype.tan = function(n, errbacks) {
42859
+ BigInteger.prototype.tan = function(errbacks) {
42848
42860
  return tan(this.toFixnum(), errbacks);
42849
42861
  };
42850
42862
 
42851
42863
  // atan: -> pyretnum
42852
42864
  // Produce the arc tangent.
42853
- BigInteger.prototype.atan = function(n, errbacks) {
42865
+ BigInteger.prototype.atan = function(errbacks) {
42854
42866
  return atan(this.toFixnum(), errbacks);
42855
42867
  };
42856
42868
 
42857
42869
  // cos: -> pyretnum
42858
42870
  // Produce the cosine.
42859
- BigInteger.prototype.cos = function(n, errbacks) {
42871
+ BigInteger.prototype.cos = function(errbacks) {
42860
42872
  return cos(this.toFixnum(), errbacks);
42861
42873
  };
42862
42874
 
42863
42875
  // sin: -> pyretnum
42864
42876
  // Produce the sine.
42865
- BigInteger.prototype.sin = function(n, errbacks) {
42877
+ BigInteger.prototype.sin = function(errbacks) {
42866
42878
  return sin(this.toFixnum(), errbacks);
42867
42879
  };
42868
42880
 
42869
42881
  // expt: pyretnum -> pyretnum
42870
42882
  // Produce the power to the input.
42871
42883
  BigInteger.prototype.expt = function(n, errbacks) {
42872
- return bnPow.call(this, n);
42884
+ return bnPow.call(this, n, errbacks);
42873
42885
  };
42874
42886
 
42875
42887
  // exp: -> pyretnum
@@ -42883,13 +42895,13 @@ define("pyret-base/js/js-numbers", function() {
42883
42895
 
42884
42896
  // acos: -> pyretnum
42885
42897
  // Produce the arc cosine.
42886
- BigInteger.prototype.acos = function(n, errbacks) {
42898
+ BigInteger.prototype.acos = function(errbacks) {
42887
42899
  return acos(this.toFixnum(), errbacks);
42888
42900
  };
42889
42901
 
42890
42902
  // asin: -> pyretnum
42891
42903
  // Produce the arc sine.
42892
- BigInteger.prototype.asin = function(n, errbacks) {
42904
+ BigInteger.prototype.asin = function(errbacks) {
42893
42905
  return asin(this.toFixnum(), errbacks);
42894
42906
  };
42895
42907