summaryrefslogtreecommitdiff
path: root/rational.c
AgeCommit message (Collapse)Author
11 daysMove more NilClass methods to rubyHartley McGuire
``` $ make benchmark ITEM=nilclass COMPARE_RUBY="/opt/rubies/ruby-master/bin/ruby" /opt/rubies/3.4.2/bin/ruby --disable=gems -rrubygems -I../benchmark/lib ../benchmark/benchmark-driver/exe/benchmark-driver \ --executables="compare-ruby::/opt/rubies/ruby-master/bin/ruby -I.ext/common --disable-gem" \ --executables="built-ruby::./miniruby -I../lib -I. -I.ext/common ../tool/runruby.rb --extout=.ext -- --disable-gems --disable-gem" \ --output=markdown --output-compare -v $(find ../benchmark -maxdepth 1 -name 'nilclass' -o -name '*nilclass*.yml' -o -name '*nilclass*.rb' | sort) compare-ruby: ruby 3.5.0dev (2025-06-02T13:52:25Z master cbd49ecbbe) +PRISM [arm64-darwin24] built-ruby: ruby 3.5.0dev (2025-06-02T22:47:21Z hm-ruby-nilclass 3e7f1f0466) +PRISM [arm64-darwin24] | |compare-ruby|built-ruby| |:------------|-----------:|---------:| |rationalize | 24.056M| 53.908M| | | -| 2.24x| |to_c | 23.652M| 82.781M| | | -| 3.50x| |to_i | 89.526M| 84.388M| | | 1.06x| -| |to_f | 84.746M| 96.899M| | | -| 1.14x| |to_r | 25.107M| 83.472M| | | -| 3.32x| |splat | 42.772M| 42.717M| | | 1.00x| -| ``` This makes them much faster
2025-01-02[DOC] Exclude 'Method' from RDoc's autolinkingNobuyoshi Nakada
Notes: Merged: https://.com/ruby/ruby/pull/12496
2024-11-08Do not round `a**b` to infinityYusuke Endoh
... instead, just calculate the value unless it is too big. Also, this change raises an ArgumentError if it is expected to exceed 16 GB in a 64-bit environment. (It is possible to calculate it straightforward, but it would likely be out-of-memory, so I didn't think it would make sense.) [Feature #20811] Notes: Merged: https://.com/ruby/ruby/pull/12033
2024-06-05[Bug #20524] win32: Suppress GMP warningNobuyoshi Nakada
``` C:\vcpkg\installed\x64-windows\include\gmp.h(2237): warning C4146: unary minus operator applied to unsigned type, result still unsigned ```
2024-04-16Eliminate usage of OBJ_FREEZE_RAWJean Boussier
Previously it would bypass the `FL_ABLE` check, but since shapes introduction, it started having a different behavior than `OBJ_FREEZE`, as it would onyl set the `FL_FREEZE` flag, but not update the shape. I have no indication of this causing a bug yet, but it seems like a trap waiting to happen.
2024-02-12Replace assert with RUBY_ASSERT in rational.cPeter Zhu
assert does not print the bug report, only the file and line number of the assertion that failed. RUBY_ASSERT prints the full bug report, which makes it much easier to debug.
2023-04-06[Feature #19474] Refactor NEWOBJ macrosMatt Valentine-House
NEWOBJ_OF is now our canonical newobj macro. It takes an optional ec Notes: Merged: https://.com/ruby/ruby/pull/7393
2023-03-13[DOC] Enhanced RDoc for NilClass (#7500)Burdette Lamar
Notes: Merged-By: peterzhu2118 <[email protected]>
2023-02-19Remove (newly unneeded) remarks about aliasesBurdetteLamar
2022-11-16Using UNDEF_P macroS-H-GAMELINKS
Notes: Merged: https://.com/ruby/ruby/pull/6721
2022-10-27Improve performance some `Integer` and `Float` methods [Feature #19085] (#6638)S.H
* Improve some Integer and Float methods * Using alias and Remove unnecessary code * Remove commentout code Notes: Merged-By: k0kubun <[email protected]>
2022-07-21Expand tabs [ci skip]Takashi Kokubun
[Misc #18891] Notes: Merged: https://.com/ruby/ruby/pull/6094
2022-05-20Disable GMP by -DUSE_GMP=0Nobuyoshi Nakada
2022-02-08[DOC] Fix broken links to literals.rdocNobuyoshi Nakada
2022-02-08[DOC] Simplify links to global methodsNobuyoshi Nakada
2021-12-03Adding links to literals and Kernel (#5192)Burdette Lamar
* Adding links to literals and Kernel Notes: Merged-By: BurdetteLamar <[email protected]>
2021-09-11Using RB_BIGNUM_TYPE_P macroS-H-GAMELINKS
Notes: Merged: https://.com/ruby/ruby/pull/4805
2021-09-02Make internal predicate functions to return simple booleanNobuyoshi Nakada
2021-08-31Remove unneeded comments in rational.cS-H-GAMELINKS
Notes: Merged: https://.com/ruby/ruby/pull/4474
2021-08-27Use C99-defined macros to classify a floating-point numberNobuyoshi Nakada
Notes: Merged: https://.com/ruby/ruby/pull/4783
2021-08-18Replace f_boolcast with RBOOL macroS.H
* Move f_boolcast definination * Remove f_boolcast macro defination * to Notes: Merged: https://.com/ruby/ruby/pull/4748 Merged-By: nobu <[email protected]>
2021-08-06Use Rational for Float#round with ndigits > 14Jeremy Evans
ndigits higher than 14 can result in values that are slightly too large due to floating point limitations. Converting to rational for the calculation and then back to float fixes these issues. Fixes [Bug #14635] Fixes [Bug #17183] Co-authored by: Yusuke Endoh <[email protected]> Notes: Merged: https://.com/ruby/ruby/pull/4682
2021-07-27Use predefined IDsNobuyoshi Nakada
Notes: Merged: https://.com/ruby/ruby/pull/4684
2021-05-12cdhash_cmp: can take rational literals卜部昌平
Rational literals are those integers suffixed with `r`. They tend to be a part of more complex expressions like `123/456r`, but in theory they can live alone. When such "bare" rational literals are passed to case-when branch, we have to take care of them. Fixes [Bug #17854] Notes: Merged: https://.com/ruby/ruby/pull/4469
2021-01-23Rationalize floats in coerce [Bug #17572]Nobuyoshi Nakada
2021-01-23Make reciprocal properly of non-integral rational [Bug #17572]Nobuyoshi Nakada
2021-01-07Follow the NDEBUG given to the wholeNobuyoshi Nakada
2020-12-09Fix ArithmeticSequence#last and ArithmeticSequence#each for non-integer ↵Kenta Murata
sequences (#3870) [Bug #17218] [ruby-core:100312] Notes: Merged-By: mrkn <[email protected]>
2020-11-10Removed canonicalization for mathnNobuyoshi Nakada
Notes: Merged: https://.com/ruby/ruby/pull/3691
2020-10-26rational.c: convert a numerator to rational before calling fdiv in ↵Kenta Murata
Kernel.Rational() (#3702) This makes `Rational(BigDecimal(1), 60) == Rational(1, 60)`. [Bug #16518] Notes: Merged-By: mrkn <[email protected]>
2020-10-22rational.c: try converting by to_int in Rational() (#3684)Kenta Murata
[Bug #12485] Notes: Merged-By: mrkn <[email protected]>
2020-10-21Don't redefine #rb_intern over and over againStefan Stüben
Notes: Merged: https://.com/ruby/ruby/pull/3589
2020-08-15RARRAY_AREF: convert into an inline function卜部昌平
RARRAY_AREF has been a macro for reasons. We might not be able to change that for public APIs, but why not relax the situation internally to make it an inline function. Notes: Merged: https://.com/ruby/ruby/pull/3419
2020-07-01Reduced working `Rational` object allocationsNobuyoshi Nakada
When rationalizing negative values.
2020-07-01Renamed `nurat_sub` compliant with `rb_rational_plus`Nobuyoshi Nakada
2020-07-01Added a few integer case short-circuitsNobuyoshi Nakada
2020-07-01Replaced f_odd_p with rb_int_odd_pNobuyoshi Nakada
2020-06-29parse_rat: 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://.com/ruby/ruby/pull/3247
2020-06-29rb_rational_cmp: 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://.com/ruby/ruby/pull/3247
2020-05-11sed -i 's|ruby/impl|ruby/internal|'卜部昌平
To fix build failures. Notes: Merged: https://.com/ruby/ruby/pull/3079
2020-05-11sed -i s|ruby/3|ruby/impl|g卜部昌平
This shall fix compile errors. Notes: Merged: https://.com/ruby/ruby/pull/3079
2020-04-21reroute redefinition of NDEBUG卜部昌平
NDEBUG can be defined via a command-line argument. Should take care of such situations.
2020-04-08Merge pull request #2991 from shyouhei/ruby.h卜部昌平
Split ruby.h Notes: Merged-By: shyouhei <[email protected]>
2020-01-17rb_rational_raw: convert num and den by to_intKenta Murata
2020-01-17rb_rational_raw: make a denominator always positiveKenta Murata
2020-01-17internal/rational.h: insert assertions in RATIONAL_SET_{NUM,DEN}Kenta Murata
2020-01-17rational.c: remove nurat_s_newKenta Murata
2020-01-17Make RATIONAL_SET_{NUM,DEN} static inline functionsKenta Murata
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://.com/ruby/ruby/pull/2711
2019-11-18Deprecate taint/trust and related methods, and make the methods no-opsJeremy Evans
This removes the related tests, and puts the related specs behind version guards. This affects all code in lib, including some libraries that may want to support older versions of Ruby. Notes: Merged: https://.com/ruby/ruby/pull/2476