summaryrefslogtreecommitdiff
path: root/bignum.c
AgeCommit message (Collapse)Author
2022-04-09[DOC]Some link prefix replaceS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/5783
2021-12-29[DOC] Integer#coerce deals with also FloatNobuyoshi Nakada
2021-12-29Fix the warning in rb_big2dbl, Bignum is no longer definedNobuyoshi Nakada
2021-12-28Remove obsolete Fixnum and BignumNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/3927
2021-11-08[Feature #18290] Remove all usages of rb_gc_force_recyclePeter Zhu
This commit removes usages of rb_gc_force_recycle since it is a burden to maintain and makes changes to the GC difficult. Notes: Merged: https://github.com/ruby/ruby/pull/4363
2021-10-12bary_mul_balance_with_mulfunc: move working buffer allocationNobuyoshi Nakada
Move the allocation of working buffer before the loop. Notes: Merged: https://github.com/ruby/ruby/pull/4949
2021-10-12bary_mul_balance_with_mulfunc: consitify invariant variablesNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4949
2021-09-15Refactor and Using RBOOL macroS.H
Notes: Merged: https://github.com/ruby/ruby/pull/4837 Merged-By: nobu <nobu@ruby-lang.org>
2021-09-13Remove uneeded initialize local variable (#4818)S.H
Notes: Merged-By: k0kubun <takashikkbn@gmail.com>
2021-09-11Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4805
2021-09-05Replace RBOOL macroS-H-GAMELINKS
Notes: Merged: https://github.com/ruby/ruby/pull/4791
2021-08-27Use C99-defined macros to classify a floating-point numberNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4783
2021-08-24Moved exported symbols in internal/util.h to ruby/util.hNobuyoshi Nakada
[Feature #18051] Notes: Merged: https://github.com/ruby/ruby/pull/4763
2021-08-09Suppress unused-variable warnings when DEBUG_INTEGER_PACKNobuyoshi Nakada
Notes: Merged: https://github.com/ruby/ruby/pull/4720
2021-03-20Remove unneeded declarations in bignum.cS.H
Notes: Merged: https://github.com/ruby/ruby/pull/4271 Merged-By: nobu <nobu@ruby-lang.org>
2021-01-23bignum.c: Make sure the argument of LONG2FIX is longYusuke Endoh
... because BDIGIT_DBL may be long long. POSFIXABLE and NEGFIXABLE ensures that the value is representable as long, but it failed to build on emscripten with -Werror -Wshorten-64-to-32.
2021-01-05[DOC] Fix grammar: "is same as" -> "is the same as"Marcus Stollsteimer
2020-12-21Fixed indefinite articles before "Integer" [ci skip]Nobuyoshi Nakada
2020-10-12bignum.c (bary_sparse_p): do not comsume Random::DEFAULTYusuke Endoh
It uses random to determine if the bignum is sparse or not. It is arguable if three-digit samples are enough or not to determine it, but anyway, consuming Random source implicitly is not good. I introduced the random sampling mechanism, and I don't know any significant reason to do so. So, let's remove it. This change makes the sampling points fixed: 40th, 50th, and 60th percentiles.
2020-10-12bignum.c (rb_int_powm): Integer#pow(0, 1) should return 0Yusuke Endoh
... instead of 1 because it requires "modulo 1". [Bug #17257]
2020-07-28Use https instead of httpKazuhiro NISHIYAMA
2020-07-14ON_DEBUG: delete unused macro卜部昌平
This is no longer used.
2020-06-29rb_big_aref: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29rb_int_parse_cstr: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29str2big_scan_digits: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-06-29bary_mul_karatsuba_branch: do not goto into a branch卜部昌平
I'm not necessarily against every goto in general, but jumping into a branch is definitely a bad idea. Better refactor. Notes: Merged: https://github.com/ruby/ruby/pull/3247
2020-05-29Respect BIGNUM_DEBUG defined by command line optionNobuyoshi Nakada
And fixed typo in compilers.yml.
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://github.com/ruby/ruby/pull/3079
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <shyouhei@ruby-lang.org>
2020-03-21Removed non-RUBY_INTEGER_UNIFICATION codeNobuyoshi Nakada
2020-03-21Leave power cache table initialized as QfalseNobuyoshi Nakada
2020-03-04suppress uninitialized variable warnings卜部昌平
Starting GCC 7, warnings about uninitialized variables are issued around them. Such warnings could be false positives (all versions of clang do not warn), but adding initializers there could never be bad things.
2020-02-08Clarified documentation in rb_integer_unpack [ci skip]Bernhard F. Brodowsky
I struggled figuring out which of the pack/unpack functions goes into which direction and the two first sentences were of the documentation were: * Import an integer into a buffer. * Export an integer into a buffer. It sounds like both of them go from a ruby integer to a buffer because both use "into". So I fixed it and went to "Import an integer from a buffer". I find this much more clear. Notes: Merged: https://github.com/ruby/ruby/pull/2891 Merged-By: nobu <nobu@ruby-lang.org>
2020-01-01bignum.c: extract bdigits_to_mpz and bdigits_from_mpz (#2805)Kenta Murata
Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2019-12-31Introduce BIGNUM_EMBED_P to check BIGNUM_EMBED_FLAG (#2802)Kenta Murata
* bignum.h: Add BIGNUM_EMBED_P * bignum.c: Use macros for handling BIGNUM_EMBED_FLAG Notes: Merged-By: mrkn <mrkn@ruby-lang.org>
2019-12-26decouple internal.h headers卜部昌平
Saves comitters' daily life by avoid #include-ing everything from internal.h to make each file do so instead. This would significantly speed up incremental builds. We take the following inclusion order in this changeset: 1. "ruby/config.h", where _GNU_SOURCE is defined (must be the very first thing among everything). 2. RUBY_EXTCONF_H if any. 3. Standard C headers, sorted alphabetically. 4. Other system headers, maybe guarded by #ifdef 5. Everything else, sorted alphabetically. Exceptions are those win32-related headers, which tend not be self- containing (headers have inclusion order dependencies). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26internal/bingnum.h rework卜部昌平
Turn macros into inline functions for better readability. Also add rb_int128t2big delcaration, which was missing. Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-12-26add several __has_something macro卜部昌平
With these macros implemented we can write codes just like we can assume the compiler being clang. MSC_VERSION_SINCE is defined to implement those macros, but turned out to be handy for other places. The -fdeclspec compiler flag is necessary for clang to properly handle __has_declspec(). Notes: Merged: https://github.com/ruby/ruby/pull/2711
2019-11-19make functions static卜部昌平
These functions are used from within a compilation unit so we can make them static, for better binary size. This changeset reduces the size of generated ruby binary from 26,590,128 bytes to 26,584,472 bytes on my macihne. Notes: Merged: https://github.com/ruby/ruby/pull/2682
2019-10-21bignum.c (estimate_initial_sqrt): prevent integer overflowYusuke Endoh
`Integer.sqrt(0xffff_ffff_ffff_ffff ** 2)` caused assertion failure because of integer overflow. [ruby-core:95453] [Bug #16269]
2019-09-10Unused LONG_MAX_as_doubleNobuyoshi Nakada
LONG_MAX_as_double is not needed when long is small enough to be exactly representable as a double, e.g., IL32LLP64 platforms.
2019-09-05interesting (but annoying) tidbit warning suppressed卜部昌平
This changeset is to suppress clang's -Wimplicit-int-float-conversion warning. In 64 bit signed long and IEEE 754 double combination (== almost everyone these days), LONG_MAX is 9,223,372,036,854,775,807. This value is _not_ exactly representable by double. The nearest value that a double can represnt is 9,223,372,036,854,775,808. It is one greater than LONG_MAX. Let's call this value the "x". The expression `LONG_MAX < yi` is a long versus double comparison. According to ISO/IEC 9899:1999 Section 6.3.1.8 (that defines the "usual rithmetic conversions"), The long value must first be casted into double. Because FLT_ROUNDS is typically 1 ("round to the nearest" mode), the conversion yields the "x" value shown above. So the comparison is in fact `x < yi`. This comparison is false for yi == x situation, i.e. yi is still bigger than LONG_MAX. On such situation the `yn = (long)yi;` statement that appear several lines below renders underfined behaviour, as per ISO/IEC 9899:1999 Section 6.3.1.3. To remedy, we just change the comparison from `<` to `<=` so that yi == x situation can properly be handled.
2019-08-03* expand tabs.git
2019-08-03Predefine some IDsNobuyoshi Nakada
2019-03-22[DOC] fix markups [ci skip]nobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67337 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-04* expand tabs.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66713 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2019-01-04introduce rb_nogvl C-API to mark ubf as async-signal-safenormal
zlib and bignum both contain unblocking functions which are async-signal-safe and do not require spawning additional threads. We can execute those functions directly in signal handlers without incurring overhead of extra threads, so provide C-API users the ability to deal with that. Other C-API users may have similar need. This flexible API can supercede existing uses of rb_thread_call_without_gvl and rb_thread_call_without_gvl2 by introducing a flags argument to control behavior. Note: this API is NOT finalized. It needs approval from other committers. I prefer shorter name than previous rb_thread_call_without_gvl* functions because my eyes requires big fonts. [Bug #15499] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66712 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-12-12complex.c: rb_complex_new_polarnobu
* complex.c (rb_complex_new_polar): renamed with _new to clarify that it creates a new instance, but is not an instance method. * complex.c (rb_complex_polar): deprecated. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66359 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2018-11-16bignum.c: fix bug in big2dbl()shyouhei
I was wrong at r65753. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65755 b2dd03c8-39d4-4d8f-98ff-823fe69b080e