bigdecimal 4.1.0-java → 4.1.2-java

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbec3e510145cedb03e4d1813d6e0ab22ff1327ee817ea9d2347e780fe6d5bf1
4
- data.tar.gz: 9442152d34a18fd79367606134622d028468edf23d6dbe3404a9eaf239788f20
3
+ metadata.gz: 44ae86902ea163c37539fb69ed9510c61829bdfbcb6e1ba02f90ca8aa4c25603
4
+ data.tar.gz: c7aa4d33cf57cf5a78f1dd23ffeb3fab30ea423189c77873904c5e059922708b
5
5
  SHA512:
6
- metadata.gz: d315846a325bdba82e62e2fe34b16a8ef01942e4485d6551e835c1739484b854593c33a7d568f10e461a27276ade554d0e80bb75666008d9502538d35867d513
7
- data.tar.gz: 7f0bf10269c3c1b3135b8d4b3dff286e5a7ad9c2f13c976f333ce3191c4fbe565f9ba35c19d041b2fbaa7bb2d7ede35e17d816c1cfb7357426f6e798eff471c2
6
+ metadata.gz: '0183b35444f3360f1a04ca9895efb7fb8d943fff443fe8f08381125b5fa8d3b3270d4b1099d3545c30899ed4cee1dec6f37377cf8f6a9f0dbd5f559b35b4fb51'
7
+ data.tar.gz: f1b848b5219995f13ac18e90cd4cdc8f0a780d4b536984d5c55d41cdefc7eb19571f0e2ac06afda3b1a82fecb1c00f99c11ea50742953ef59f156febfd914840
@@ -637,7 +637,7 @@ module BigMath
637
637
  return BigDecimal::Internal.nan_computation_result if x.nan?
638
638
  return BigDecimal(1 - x.infinite?) if x.infinite?
639
639
  return BigDecimal(1).sub(erf(x, prec + BigDecimal::Internal::EXTRA_PREC), prec) if x < 0.5
640
- return BigDecimal(0) if x > 5000000000 # erfc(5000000000) < 1e-10000000000000000000 (underflow)
640
+ return BigDecimal::Internal.underflow_computation_result if x > 5000000000 # erfc(5000000000) < 1e-10000000000000000000 (underflow)
641
641
 
642
642
  if x >= 8
643
643
  y = _erfc_asymptotic(x, prec)
data/lib/bigdecimal.rb CHANGED
@@ -57,6 +57,13 @@ class BigDecimal
57
57
  BigDecimal::INFINITY
58
58
  end
59
59
 
60
+ def self.underflow_computation_result # :nodoc:
61
+ if BigDecimal.mode(BigDecimal::EXCEPTION_ALL).anybits?(BigDecimal::EXCEPTION_UNDERFLOW)
62
+ raise FloatDomainError, 'Exponent underflow'
63
+ end
64
+ BigDecimal(0)
65
+ end
66
+
60
67
  def self.nan_computation_result # :nodoc:
61
68
  if BigDecimal.mode(BigDecimal::EXCEPTION_ALL).anybits?(BigDecimal::EXCEPTION_NaN)
62
69
  raise FloatDomainError, "Computation results to 'NaN'"
@@ -350,7 +357,17 @@ module BigMath
350
357
  prec = BigDecimal::Internal.coerce_validate_prec(prec, :exp)
351
358
  x = BigDecimal::Internal.coerce_to_bigdecimal(x, prec, :exp)
352
359
  return BigDecimal::Internal.nan_computation_result if x.nan?
353
- return x.positive? ? BigDecimal::Internal.infinity_computation_result : BigDecimal(0) if x.infinite?
360
+ if x.infinite? || x.exponent >= 21 # exp(10**20) and exp(-10**20) overflows/underflows 64-bit exponent
361
+ if x.positive?
362
+ return BigDecimal::Internal.infinity_computation_result
363
+ elsif x.infinite?
364
+ # exp(-Infinity) is +0 by definition, this is not an underflow.
365
+ return BigDecimal(0)
366
+ else
367
+ return BigDecimal::Internal.underflow_computation_result
368
+ end
369
+ end
370
+
354
371
  return BigDecimal(1) if x.zero?
355
372
 
356
373
  # exp(x * 10**cnt) = exp(x)**(10**cnt)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bigdecimal
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.0
4
+ version: 4.1.2
5
5
  platform: java
6
6
  authors:
7
7
  - Kenta Murata