1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

bigdecimal: version 1.3.0.pre.2

Import bigdecimal version 1.3.0.pre.2.  The full commit log is here:

  https://github.com/ruby/bigdecimal/compare/v1.3.0.pre...v1.3.0.pre.2

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57044 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
mrkn 2016-12-10 08:56:05 +00:00
parent 30540c5675
commit 42a677c895
3 changed files with 30 additions and 21 deletions

View file

@ -4003,26 +4003,6 @@ VpAlloc(size_t mx, const char *szVal)
return vp; return vp;
} }
/* Check on Inf & NaN */
if (StrCmp(szVal, SZ_PINF) == 0 || StrCmp(szVal, SZ_INF) == 0 ) {
vp = VpAllocReal(1);
vp->MaxPrec = 1; /* set max precision */
VpSetPosInf(vp);
return vp;
}
if (StrCmp(szVal, SZ_NINF) == 0) {
vp = VpAllocReal(1);
vp->MaxPrec = 1; /* set max precision */
VpSetNegInf(vp);
return vp;
}
if (StrCmp(szVal, SZ_NaN) == 0) {
vp = VpAllocReal(1);
vp->MaxPrec = 1; /* set max precision */
VpSetNaN(vp);
return vp;
}
/* Skip all '_' after digit: 2006-6-30 */ /* Skip all '_' after digit: 2006-6-30 */
ni = 0; ni = 0;
buf = rb_str_tmp_new(strlen(szVal) + 1); buf = rb_str_tmp_new(strlen(szVal) + 1);
@ -4048,6 +4028,26 @@ VpAlloc(size_t mx, const char *szVal)
} }
szVal = psz; szVal = psz;
/* Check on Inf & NaN */
if (StrCmp(szVal, SZ_PINF) == 0 || StrCmp(szVal, SZ_INF) == 0 ) {
vp = VpAllocReal(1);
vp->MaxPrec = 1; /* set max precision */
VpSetPosInf(vp);
return vp;
}
if (StrCmp(szVal, SZ_NINF) == 0) {
vp = VpAllocReal(1);
vp->MaxPrec = 1; /* set max precision */
VpSetNegInf(vp);
return vp;
}
if (StrCmp(szVal, SZ_NaN) == 0) {
vp = VpAllocReal(1);
vp->MaxPrec = 1; /* set max precision */
VpSetNaN(vp);
return vp;
}
/* check on number szVal[] */ /* check on number szVal[] */
ipn = i = 0; ipn = i = 0;
if (szVal[i] == '-') { sign=-1; ++i; } if (szVal[i] == '-') { sign=-1; ++i; }

View file

@ -1,5 +1,5 @@
# coding: utf-8 # coding: utf-8
_VERSION = '1.3.0.pre' _VERSION = '1.3.0.pre.2'
Gem::Specification.new do |s| Gem::Specification.new do |s|
s.name = "bigdecimal" s.name = "bigdecimal"

View file

@ -53,6 +53,15 @@ class TestBigDecimal < Test::Unit::TestCase
assert_equal(1, BigDecimal("1")) assert_equal(1, BigDecimal("1"))
assert_equal(1, BigDecimal("1", 1)) assert_equal(1, BigDecimal("1", 1))
assert_raise(ArgumentError) { BigDecimal("1", -1) } assert_raise(ArgumentError) { BigDecimal("1", -1) }
BigDecimal.save_exception_mode do
BigDecimal.mode(BigDecimal::EXCEPTION_OVERFLOW, false)
BigDecimal.mode(BigDecimal::EXCEPTION_NaN, false)
assert_equal(1234, BigDecimal(" \t\n\r \r1234 \t\n\r \r"))
assert_positive_infinite(BigDecimal(" \t\n\r \rInfinity \t\n\r \r"))
assert_negative_infinite(BigDecimal(" \t\n\r \r-Infinity \t\n\r \r"))
assert_nan(BigDecimal(" \t\n\r \rNaN \t\n\r \r"))
end
end end
def test_global_new_with_invalid_string def test_global_new_with_invalid_string