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 +4 -4
- data/lib/bigdecimal/math.rb +1 -1
- data/lib/bigdecimal.rb +18 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 44ae86902ea163c37539fb69ed9510c61829bdfbcb6e1ba02f90ca8aa4c25603
|
|
4
|
+
data.tar.gz: c7aa4d33cf57cf5a78f1dd23ffeb3fab30ea423189c77873904c5e059922708b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '0183b35444f3360f1a04ca9895efb7fb8d943fff443fe8f08381125b5fa8d3b3270d4b1099d3545c30899ed4cee1dec6f37377cf8f6a9f0dbd5f559b35b4fb51'
|
|
7
|
+
data.tar.gz: f1b848b5219995f13ac18e90cd4cdc8f0a780d4b536984d5c55d41cdefc7eb19571f0e2ac06afda3b1a82fecb1c00f99c11ea50742953ef59f156febfd914840
|
data/lib/bigdecimal/math.rb
CHANGED
|
@@ -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
|
|
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
|
-
|
|
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)
|