Commit graph

373 commits

Author SHA1 Message Date
Kenta Murata
ccabf4966f [ruby/bigdecimal] Fix length calculation in rb_uint64_convert_to_BigDecimal
14e53ed7f6
2021-01-12 17:38:43 +09:00
Kenta Murata
1d04faee23 [ruby/bigdecimal] Use rb_cstr_convert_to_BigDecimal in GetVpValueWithPrec
381ddf5ff6
2021-01-12 09:22:14 +09:00
Kenta Murata
78d3813c74 [ruby/bigdecimal] Add rb_cstr_convert_to_BigDecimal
ac230a996e
2021-01-12 09:21:58 +09:00
Kenta Murata
2e9b6096a6 [ruby/bigdecimal] Fix type name
2dad4d17b2
2021-01-10 08:40:05 +09:00
Kenta Murata
8b53cbaf5e
[ruby/bigdecimal] Avoid casting negative value to size_t
https://github.com/ruby/bigdecimal/f047b2786f
2021-01-10 08:36:29 +09:00
Kenta Murata
72d504c1fd
[ruby/bigdecimal] Use smallest local variable scope in GetVpValueWithPrec
44f26b9aa0
2021-01-10 08:35:43 +09:00
Kenta Murata
3d9c95996d
[ruby/bigdecimal] Stop using GetVpValueWithPrec in rb_rational_convert_to_BigDecimal
b4f470da61
44a78df866
2021-01-09 20:36:47 +09:00
Kenta Murata
be34e31d8e [ruby/bigdecimal] Add assertions for checking the argument types
96c9ebd886
2021-01-09 20:36:18 +09:00
Kenta Murata
fb18a8113a
[ruby/bigdecimal] Stop using GetVpValueWithPrec in rb_float_convert_to_BigDecimal
33e7c50263
d3c1b0b921
2021-01-09 20:35:52 +09:00
Kenta Murata
82f6085b3e [ruby/bigdecimal] Fix trailing zero handling in rb_uint64_convert_to_BigDecimal
2056604d56
2021-01-07 10:20:40 +09:00
Kenta Murata
fa8295ccb9
[ruby/bigdecimal] Rename BDIGIT to DECDIG
686487d942
2021-01-06 13:52:12 +09:00
Kenta Murata
7da06c04b2
Need to convert the return value of rb_big_cmp 2021-01-06 13:39:09 +09:00
Kenta Murata
f289f8ae3a [ruby/bigdecimal] Optimize the conversion from small Bignum
4792a917d8
2021-01-06 10:56:48 +09:00
Kenta Murata
71f0dd339b
[ruby/bigdecimal] Move some definitions to missing.h
c2b22cc8b3
8cbca8481d
f05aecf673
2021-01-04 13:29:10 +09:00
Kenta Murata
448a67cd81
[ruby/bigdecimal] Implement special conversions for 64-bit integers
This change improves the conversion speed from small integers.

```
Comparison:
                           big_n9
              master:   4003688.9 i/s
    bigdecimal 3.0.0:   1270551.0 i/s - 3.15x  slower

                          big_n19
              master:   5410096.4 i/s
    bigdecimal 3.0.0:   1000250.3 i/s - 5.41x  slower
```

3429bd7e6f
2021-01-02 00:54:09 +09:00
Kenta Murata
a8014dae47 [ruby/bigdecimal] Refactor object allocation
271cebe567
2020-12-31 02:05:02 +09:00
Kenta Murata
4569e46550 [ruby/bigdecimal] Remove ToValue
97e9feeebd
2020-12-31 02:04:53 +09:00
Kenta Murata
8d93c1e70f [ruby/bigdecimal] Remove VP_EXCEPTION_MEMORY
It is no longer used due to the previous commit.

7d463f802b
2020-12-30 00:22:21 +09:00
Kenta Murata
086f3f1872 [ruby/bigdecimal] Remove needless pointer checks
xmalloc and xrealloc return non-NULL pointers or raise memory error.

507f0a6a64
2020-12-30 00:22:11 +09:00
Kenta Murata
29d012c964
[ruby/bigdecimal] Alloc wrapper object before VpAlloc
Calling TypedData_Wrap_Struct after VpAlloc may cause memory leak.

This commit reverts d11b78f9c4.

2c5a288caf
2020-12-29 17:46:36 +09:00
Kenta Murata
13b520d578
[ruby/bigdecimal] Refactor to extract VpCheckException
6fd171308b
2020-12-29 17:46:36 +09:00
Kenta Murata
512e08895f [ruby/bigdecimal] Refactor to decompose VpNewVarArg into small functions
7504871c48
2020-12-29 12:56:10 +09:00
Kenta Murata
d11b78f9c4 [ruby/bigdecimal] Reduce needless object allocation in f_BigDecimal
5c808eeabb
2020-12-29 12:54:39 +09:00
Kenta Murata
06b44f819e [ruby/bigdecimal] [Doc] Fix the document of BigDecimal()
[ci-skip]

905d0345ec
2020-12-28 21:26:26 +09:00
Kenta Murata
80d9e457c5
[ruby/bigdecimal] Reduce conditional branch count in VpNewVarArg
741fb3e00f
2020-12-28 21:16:48 +09:00
Nobuyoshi Nakada
c01ad11f90
bigdecimal: initialize conditionally assigned variable 2020-12-20 03:13:33 +09:00
Kenta Murata
df3deb3baa
[bigdecimal] Add BigDecimal#n_significant_digits
981dc48f95
9ecf880ec0
2020-12-19 22:13:59 +09:00
Kenta Murata
654f6fbf19
[bigdecimal] Make BigDecimal#precs deprecated
7e80e6e145
0ed7846e8c
2020-12-19 22:13:58 +09:00
Kenta Murata
ff9e40811c
[bigdecimal] Add BigDecimal#precision
458eb66c49
2020-12-19 22:13:58 +09:00
Kenta Murata
928a06723d
[bigdecimal] Make bigdecimal Ractor safe
93fc392640
a90d13c4d0
2020-12-19 22:13:57 +09:00
Kenta Murata
97d4e72e0b
[bigdecimal] Use DBLE_FIG
12296dcb90
2020-12-19 22:13:57 +09:00
Kenta Murata
e1424c3501
[bigdecimal] Fix the default precision of Float#to_d
Fix https://github.com/ruby/bigdecimal/issues/70
[Bug #13331]

aa536cd4b5
2020-12-19 22:13:53 +09:00
Kenta Murata
d5ab8e8562
[bigdecimal] Use rb_undef_alloc_func to undefine allocate 2020-12-19 02:29:31 +09:00
Kenta Murata
a86c147579
Import bigdecimal 2.0.2 (#3905)
* remove duplicated include

* Make BigDecimal#round with argument < 1 return Integer

Fixes [Bug #12780]

* Use a higher default precision for BigDecimal#power and #**

When a fractional power is given, increase the precision if the
precision isn't specified via power's second argument:

Float: increase by 15 (rough number of decimal precision in float)
BigDecimal: increase by adding similar precision modifier as done to
            calculate the base precision.
Rational: double the precision, since a BigDecimal is created, but
          the created BigDecimal uses the same precision.

Increasing the precision for these power calculations has the obvious
tradeoff of making the calculations slower.

Fixes Ruby Bug #17264

* Use DBLE_FIG for a Float value

* Version 2.0.1

Co-authored-by: pavel <pavel.rosicky@easy.cz>
Co-authored-by: Jeremy Evans <code@jeremyevans.net>
2020-12-15 15:17:15 +09:00
Ikko Ashimine
df25007046 Fixed typo in comment
alway -> always
2020-10-10 02:32:21 -04:00
Kenta Murata
6a826eb4b0
[ruby/bigdecimal] Return US-ASCII string from BigDecimal#to_s
Fixes #159

57ee92e700
2020-07-06 01:15:47 +09:00
Kenta Murata
40b82afe6a
[ruby/bigdecimal] Support Ruby < 2.6
61ec452599
2020-07-06 01:15:46 +09:00
Jeremy Evans
d36b197d7c
[ruby/bigdecimal] Remove definition of BigDecimal#initialize_copy
This leaves the default definition, which will raise FrozenError.

05e843d838
2020-07-06 01:15:46 +09:00
Kenta Murata
f00efef30a
[ruby/bigdecimal] Support a Complex in Kernel.BigDecimal()
00795cb01f
2020-07-06 01:15:46 +09:00
Jeremy Evans
ceb9d516c6
[ruby/bigdecimal] Undef BigDecimal#initialize_copy
Both BigDecimal#clone and BigDecimal#dup return self, there is no
reason to have initialize_copy exposed as a Ruby method.

The same is true for initialize_clone and initialize_dup.

aaf237fa9e
2020-07-06 01:15:45 +09:00
Yusuke Endoh
61d451d6ce ext/bigdecimal/bigdecimal.c, ext/date/date_core.c: undef NDEBUG
`#define NDEBUG` produces "macro redefined" warnings when it is already
defined via cppflags
2020-05-13 13:49:21 +09:00
Nobuyoshi Nakada
d8720eb7de
Suppress -Wshorten-64-to-32 warnings 2020-04-08 16:28:38 +09:00
Jeremy Evans
b38b26c62d
[ruby/bigdecimal] Remove taint checking
This removes the taint checking.  Taint support is deprecated in
Ruby 2.7 and has no effect.  I don't think removing the taint
checks in earlier ruby versions will cause any problems.

1918d466f3
2019-11-12 11:16:07 +09:00
Kenta Murata
dd0c75fdc2
Import changes from ruby/bigdecimal (#2531)
Sync to ruby/bigdecimal@92356ba71c
2019-10-08 09:06:28 +09:00
Jeremy Evans
2e551356a7 Make Kernel#{Pathname,BigDecimal,Complex} return argument if given correct type
This is how Kernel#{Array,String,Float,Integer,Hash,Rational} work.
BigDecimal and Complex instances are always frozen, so this should
not cause backwards compatibility issues for those.  Pathname
instances are not frozen, so potentially this could cause backwards
compatibility issues by not returning a new object.

Based on a patch from Joshua Ballanco, some minor changes by me.

Fixes [Bug #7522]
2019-09-21 16:10:37 -07:00
Nobuyoshi Nakada
8745fa2ff0
Default to true when no exception flag [Bug #15987] 2019-07-11 21:05:25 +09:00
Nobuyoshi Nakada
f74e23af32
Fixed argument in the fallback function [Bug #15987] 2019-07-11 20:21:50 +09:00
Nobuyoshi Nakada
c2723e59c2
Removed wrong argument in the fallback function [Bug #15987] 2019-07-11 20:20:02 +09:00
Nobuyoshi Nakada
3e7d002118
Check exception flag as a bool [Bug #15987] 2019-07-11 20:04:29 +09:00
mrkn
8754b2391b Import bigdecimal-1.4.0
* https://github.com/ruby/bigdecimal/compare/v1.4.0.pre.20181220a..v1.4.0

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66516 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-23 18:32:01 +00:00