<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_integer.rb, 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) 1cdf8ab07b24ebd16e93621957196e8b1d67f2ba: [Backport #19323]</title>
<updated>2023-06-25T02:52:21+00:00</updated>
<author>
<name>nagachika</name>
<email>nagachika@ruby-lang.org</email>
</author>
<published>2023-06-25T02:52:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=a048f7882a13e96080021a5bc13ef1fb293b4985'/>
<id>a048f7882a13e96080021a5bc13ef1fb293b4985</id>
<content type='text'>
	[Bug #19323] Raise `RangeError` instead of integer overflow

	---
	 bignum.c                  |  5 ++++-
	 test/ruby/test_integer.rb | 18 ++++++++----------
	 2 files changed, 12 insertions(+), 11 deletions(-)
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
	[Bug #19323] Raise `RangeError` instead of integer overflow

	---
	 bignum.c                  |  5 ++++-
	 test/ruby/test_integer.rb | 18 ++++++++----------
	 2 files changed, 12 insertions(+), 11 deletions(-)
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #18998] Honor `#to_str` next to `#to_int` in `Kernel#Integer`</title>
<updated>2022-10-20T06:35:31+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2022-10-20T05:07:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=7563604fb868d87057733f52d780d841fc1ab6bb'/>
<id>7563604fb868d87057733f52d780d841fc1ab6bb</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>Don't call + and &lt; in Integer.times for !FIXNUM</title>
<updated>2021-12-02T00:21:50+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-12-01T21:00:11+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fe1725236c8a4d6cb780874c470f7f443185ed38'/>
<id>fe1725236c8a4d6cb780874c470f7f443185ed38</id>
<content type='text'>
The methods aren't called for FIXNUM, and it's best to have
consistent behavior.

Fixes [Bug #18377]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The methods aren't called for FIXNUM, and it's best to have
consistent behavior.

Fixes [Bug #18377]
</pre>
</div>
</content>
</entry>
<entry>
<title>Improve performance of Integer#digits</title>
<updated>2021-07-29T22:19:12+00:00</updated>
<author>
<name>Jeremy Evans</name>
<email>code@jeremyevans.net</email>
</author>
<published>2021-06-17T18:27:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=9931e2f5091e95dd947de3b3a00167ae2fd5194a'/>
<id>9931e2f5091e95dd947de3b3a00167ae2fd5194a</id>
<content type='text'>
This speeds up performance by multiple orders of magnitude for
large integers.

Fixes [Bug #14391]

Co-authored-by: tompng (tomoya ishida) &lt;tomoyapenguin@gmail.com&gt;
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
This speeds up performance by multiple orders of magnitude for
large integers.

Fixes [Bug #14391]

Co-authored-by: tompng (tomoya ishida) &lt;tomoyapenguin@gmail.com&gt;
</pre>
</div>
</content>
</entry>
<entry>
<title>Add Integer.try_convert [Feature #15211]</title>
<updated>2021-07-16T08:49:53+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2018-10-07T04:02:46+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=301d194ee3b49e6b078eccb999dd538e9bfa8c7c'/>
<id>301d194ee3b49e6b078eccb999dd538e9bfa8c7c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix unsigned int overflow in error message for chr</title>
<updated>2020-09-29T15:31:59+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2020-09-28T21:35:27+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f7bd9f075030e5fa876320c1624a80685a636e82'/>
<id>f7bd9f075030e5fa876320c1624a80685a636e82</id>
<content type='text'>
The error message has an integer overflow because it treats an unsigned int as a signed int.

Before:
```
&gt; 3_000_000_000.chr
-1294967296 out of char range (RangeError)
```

After:
```
&gt; 3_000_000_000.chr
3000000000 out of char range (RangeError)
```

Redmine ticket: https://bugs.ruby-lang.org/issues/17186
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The error message has an integer overflow because it treats an unsigned int as a signed int.

Before:
```
&gt; 3_000_000_000.chr
-1294967296 out of char range (RangeError)
```

After:
```
&gt; 3_000_000_000.chr
3000000000 out of char range (RangeError)
```

Redmine ticket: https://bugs.ruby-lang.org/issues/17186
</pre>
</div>
</content>
</entry>
<entry>
<title>bignum.c (estimate_initial_sqrt): prevent integer overflow</title>
<updated>2019-10-21T12:24:21+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2019-10-21T12:22:53+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=f364564e66d1db1de8e80d669287386595c8bc46'/>
<id>f364564e66d1db1de8e80d669287386595c8bc46</id>
<content type='text'>
`Integer.sqrt(0xffff_ffff_ffff_ffff ** 2)` caused assertion failure
because of integer overflow.  [ruby-core:95453] [Bug #16269]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`Integer.sqrt(0xffff_ffff_ffff_ffff ** 2)` caused assertion failure
because of integer overflow.  [ruby-core:95453] [Bug #16269]
</pre>
</div>
</content>
</entry>
</feed>
