<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/numeric.c, branch v3_2_11</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Fix ceil when ndigits is large</title>
<updated>2024-08-02T09:26:26+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-07-26T15:10:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7fc6448ec7f7505ca5772af0a60ee780c321492c'/>
<id>7fc6448ec7f7505ca5772af0a60ee780c321492c</id>
<content type='text'>
[Bug #20654]

This commit fixes Integer#ceil and Float#ceil when the number is
negative and ndigits is large such that 10**ndigits is a bignum.

Previously, it would return 0 in such cases. However, this would cause
unexpected behaviour such as:

    puts 1.ceil(-5) # =&gt; 100000
    puts 1.ceil(-10) # =&gt; 10000000000
    puts 1.ceil(-20) # =&gt; 0

This commit changes the last result so that it will return
100000000000000000000.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Bug #20654]

This commit fixes Integer#ceil and Float#ceil when the number is
negative and ndigits is large such that 10**ndigits is a bignum.

Previously, it would return 0 in such cases. However, this would cause
unexpected behaviour such as:

    puts 1.ceil(-5) # =&gt; 100000
    puts 1.ceil(-10) # =&gt; 10000000000
    puts 1.ceil(-20) # =&gt; 0

This commit changes the last result so that it will return
100000000000000000000.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix floor when ndigits is large</title>
<updated>2024-08-02T09:26:26+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-07-26T15:10:39+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7048fbdf59509e4f52eff56d7c044ed28eb67727'/>
<id>7048fbdf59509e4f52eff56d7c044ed28eb67727</id>
<content type='text'>
[Bug #20654]

This commit fixes Integer#floor and Float#floor when the number is
negative and ndigits is large such that 10**ndigits is a bignum.

Previously, it would return 0 in such cases. However, this would cause
unexpected behaviour such as:

    puts -1.floor(-5) # =&gt; -100000
    puts -1.floor(-10) # =&gt; -10000000000
    puts -1.floor(-20) # =&gt; 0

This commit changes the last result so that it will return
-100000000000000000000.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Bug #20654]

This commit fixes Integer#floor and Float#floor when the number is
negative and ndigits is large such that 10**ndigits is a bignum.

Previously, it would return 0 in such cases. However, this would cause
unexpected behaviour such as:

    puts -1.floor(-5) # =&gt; -100000
    puts -1.floor(-10) # =&gt; -10000000000
    puts -1.floor(-20) # =&gt; 0

This commit changes the last result so that it will return
-100000000000000000000.
</pre>
</div>
</content>
</entry>
<entry>
<title>merge revision(s) dd28c55a7cd6780dad637b4d6a20507fbfc6af4a: [Backport #19445]</title>
<updated>2023-03-08T03:02:22+00:00</updated>
<author>
<name>NARUSE, Yui</name>
<email>naruse@airemix.jp</email>
</author>
<published>2023-03-08T03:02:22+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=59eb18037ff92839be48fb6c46ff0acc179b4f4c'/>
<id>59eb18037ff92839be48fb6c46ff0acc179b4f4c</id>
<content type='text'>
	[Bug#19445] Fix keyword splat in enumerator

	Extracted arguments do not have keyword hash to splat.
	---
	 numeric.c                 | 2 +-
	 test/ruby/test_numeric.rb | 3 +++
	 2 files changed, 4 insertions(+), 1 deletion(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug#19445] Fix keyword splat in enumerator

	Extracted arguments do not have keyword hash to splat.
	---
	 numeric.c                 | 2 +-
	 test/ruby/test_numeric.rb | 3 +++
	 2 files changed, 4 insertions(+), 1 deletion(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>Using UNDEF_P macro</title>
<updated>2022-11-16T09:58:33+00:00</updated>
<author>
<name>S-H-GAMELINKS</name>
<email>gamelinks007@gmail.com</email>
</author>
<published>2022-11-15T04:24:08+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6'/>
<id>1f4f6c9832d83e7ebd65ccf4e95cef358b3512c6</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Use `roomof` macro for rounding up divisions</title>
<updated>2022-10-14T10:23:25+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-10-04T09:10:41+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5ccb625fbbd1e774636a9fdbe0bf1c3d38e085d5'/>
<id>5ccb625fbbd1e774636a9fdbe0bf1c3d38e085d5</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Improve performance of Integer#ceildiv</title>
<updated>2022-08-12T06:57:52+00:00</updated>
<author>
<name>Kouhei Yanagita</name>
<email>yanagi@shakenbu.org</email>
</author>
<published>2022-07-22T03:05:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=803a07263001e5466bba0f53fcc85784f4b5c686'/>
<id>803a07263001e5466bba0f53fcc85784f4b5c686</id>
<content type='text'>
This patch is suggested by nobu.

Benchmark result:

```
require 'benchmark'

n = 10 ** 7

Benchmark.bm do |x|
  x.report("Fixnum/Fixnum") { a, b = 5, 2; n.times { a.ceildiv(b) } }
  x.report("Bignum/Bignum") { a, b = 10**100, 10**99 - 1; n.times { a.ceildiv(b) } }
  x.report("Bignum/Fixnum") { a, b = 10**100, 3; n.times { a.ceildiv(b) } }
end
```

Original:

```
       user     system      total        real
Fixnum/Fixnum  3.340009   0.043029   3.383038 (  3.384022)
Bignum/Bignum  8.229500   0.118543   8.348043 (  8.349574)
Bignum/Fixnum  8.328971   0.097842   8.426813 (  8.426952)
```

Improved:

```
       user     system      total        real
Fixnum/Fixnum  0.699140   0.000961   0.700101 (  0.700199)
Bignum/Bignum  5.076165   0.083160   5.159325 (  5.159360)
Bignum/Fixnum  5.548684   0.115372   5.664056 (  5.666735)
```
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This patch is suggested by nobu.

Benchmark result:

```
require 'benchmark'

n = 10 ** 7

Benchmark.bm do |x|
  x.report("Fixnum/Fixnum") { a, b = 5, 2; n.times { a.ceildiv(b) } }
  x.report("Bignum/Bignum") { a, b = 10**100, 10**99 - 1; n.times { a.ceildiv(b) } }
  x.report("Bignum/Fixnum") { a, b = 10**100, 3; n.times { a.ceildiv(b) } }
end
```

Original:

```
       user     system      total        real
Fixnum/Fixnum  3.340009   0.043029   3.383038 (  3.384022)
Bignum/Bignum  8.229500   0.118543   8.348043 (  8.349574)
Bignum/Fixnum  8.328971   0.097842   8.426813 (  8.426952)
```

Improved:

```
       user     system      total        real
Fixnum/Fixnum  0.699140   0.000961   0.700101 (  0.700199)
Bignum/Bignum  5.076165   0.083160   5.159325 (  5.159360)
Bignum/Fixnum  5.548684   0.115372   5.664056 (  5.666735)
```
</pre>
</div>
</content>
</entry>
<entry>
<title>Remove Numeric#ceildiv</title>
<updated>2022-08-12T06:57:52+00:00</updated>
<author>
<name>Kouhei Yanagita</name>
<email>yanagi@shakenbu.org</email>
</author>
<published>2022-07-21T09:57:13+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=24e33b84b5adb29d1d2f541acfba65e225b91b55'/>
<id>24e33b84b5adb29d1d2f541acfba65e225b91b55</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Add Numeric#ceildiv and Integer#ceildiv</title>
<updated>2022-08-12T06:57:52+00:00</updated>
<author>
<name>Kouhei Yanagita</name>
<email>yanagi@shakenbu.org</email>
</author>
<published>2022-05-27T06:46:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=4165fd0e763439421296fbc95d754ad53e6ae84f'/>
<id>4165fd0e763439421296fbc95d754ad53e6ae84f</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Expand tabs [ci skip]</title>
<updated>2022-07-21T16:42:04+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2022-07-21T16:23:58+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5b21e94bebed90180d8ff63dad03b8b948361089'/>
<id>5b21e94bebed90180d8ff63dad03b8b948361089</id>
<content type='text'>
[Misc #18891]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
[Misc #18891]
</pre>
</div>
</content>
</entry>
<entry>
<title>[DOC] Fix documentation of Numeric#div: Complex does not have #div</title>
<updated>2022-06-03T05:35:47+00:00</updated>
<author>
<name>Kouhei Yanagita</name>
<email>yanagi@shakenbu.org</email>
</author>
<published>2022-05-27T21:04:02+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a4721ec6cdd32b9c23a009e7390fefa1d9148ffd'/>
<id>a4721ec6cdd32b9c23a009e7390fefa1d9148ffd</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
