Skip to content

Commit ffa10b2

Browse files
authored
Merge branch 'master' into add_bigmath_tan
2 parents 46dca76 + 0b85aa6 commit ffa10b2

File tree

6 files changed

+20
-12
lines changed

6 files changed

+20
-12
lines changed

.github/workflows/benchmark.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ jobs:
3737
exclude:
3838
- { os: windows-latest , ruby: debug }
3939

40+
# These are disabled due to the ambiguity of stringio
41+
- { os: windows-latest , ruby: "3.0" }
42+
- { os: windows-latest , ruby: "3.1" }
43+
- { os: windows-latest , ruby: "3.2" }
44+
4045
steps:
4146
- uses: actions/checkout@v4
4247

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGES
22

3+
## 3.1.9
4+
5+
* Accept no digits in the fractional part (#302)
6+
7+
**@kou**
8+
39
## 3.1.8
410

511
* Add missing documents [GH-277]

ext/bigdecimal/bigdecimal.c

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#include "bits.h"
3232
#include "static_assert.h"
3333

34-
#define BIGDECIMAL_VERSION "3.1.8"
34+
#define BIGDECIMAL_VERSION "3.1.9"
3535

3636
/* #define ENABLE_NUMERIC_STRING */
3737

@@ -5277,7 +5277,7 @@ VP_EXPORT Real *
52775277
VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
52785278
{
52795279
const char *orig_szVal = szVal;
5280-
size_t i, j, ni, ipf, nf, ipe, ne, dot_seen, exp_seen, nalloc;
5280+
size_t i, j, ni, ipf, nf, ipe, ne, exp_seen, nalloc;
52815281
size_t len;
52825282
char v, *psz;
52835283
int sign=1;
@@ -5363,13 +5363,11 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
53635363
ne = 0; /* number of digits in the exponential part */
53645364
ipf = 0; /* index of the beginning of the fractional part */
53655365
ipe = 0; /* index of the beginning of the exponential part */
5366-
dot_seen = 0;
53675366
exp_seen = 0;
53685367

53695368
if (v != '\0') {
53705369
/* Scanning fractional part */
53715370
if ((psz[i] = szVal[j]) == '.') {
5372-
dot_seen = 1;
53735371
++i;
53745372
++j;
53755373
ipf = i;
@@ -5385,9 +5383,6 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
53855383
}
53865384
if (!strict_p) {
53875385
v = psz[i] = '\0';
5388-
if (nf == 0) {
5389-
dot_seen = 0;
5390-
}
53915386
break;
53925387
}
53935388
goto invalid_value;
@@ -5458,7 +5453,7 @@ VpAlloc(size_t mx, const char *szVal, int strict_p, int exc)
54585453

54595454
psz[i] = '\0';
54605455

5461-
if (strict_p && (((ni == 0 || dot_seen) && nf == 0) || (exp_seen && ne == 0))) {
5456+
if (strict_p && ((ni == 0 && nf == 0) || (exp_seen && ne == 0))) {
54625457
VALUE str;
54635458
invalid_value:
54645459
if (!strict_p) {

ext/bigdecimal/missing.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
_Pragma("GCC diagnostic push") \
1616
_Pragma("GCC diagnostic ignored \"-Wattributes\"") \
1717
__attribute__((__no_sanitize__(x))) y; \
18-
_Pragma("GCC diagnostic pop")
18+
_Pragma("GCC diagnostic pop") \
19+
y
1920
#endif
2021

2122
#undef strtod

lib/bigdecimal/math.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@
88
# sin (x, prec)
99
# cos (x, prec)
1010
# tan (x, prec)
11-
# atan(x, prec) Note: |x|<1, x=0.9999 may not converge.
11+
# atan(x, prec)
1212
# PI (prec)
1313
# E (prec) == exp(1.0,prec)
1414
#
1515
# where:
1616
# x ... BigDecimal number to be computed.
17-
# |x| must be small enough to get convergence.
1817
# prec ... Number of digits to be obtained.
1918
#++
2019
#

test/bigdecimal/test_bigdecimal.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ def test_BigDecimal
7474
assert_equal(111, BigDecimal("1_1_1_"))
7575
assert_equal(10**(-1), BigDecimal("1E-1"), '#4825')
7676
assert_equal(1234, BigDecimal(" \t\n\r \r1234 \t\n\r \r"))
77+
assert_equal(0.0, BigDecimal("0."))
78+
assert_equal(0.0E-9, BigDecimal("0.E-9"))
7779

7880
assert_raise(ArgumentError) { BigDecimal("1", -1) }
7981
assert_raise_with_message(ArgumentError, /"1__1_1"/) { BigDecimal("1__1_1") }
@@ -295,7 +297,7 @@ def test_s_ver
295297

296298
def test_s_allocate
297299
if RUBY_ENGINE == "truffleruby"
298-
assert_raise_with_message(NoMethodError, /undefined.+allocate.+for BigDecimal/) { BigDecimal.allocate }
300+
assert_raise_with_message(NoMethodError, /undefined.+allocate.+for.+BigDecimal/) { BigDecimal.allocate }
299301
else
300302
assert_raise_with_message(TypeError, /allocator undefined for BigDecimal/) { BigDecimal.allocate }
301303
end

0 commit comments

Comments
 (0)