<feed xmlns='http://www.w3.org/2005/Atom'>
<title>ruby.git/test/ruby/test_integer.rb, branch v4.0.4</title>
<subtitle>The Ruby Programming Language</subtitle>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/'/>
<entry>
<title>Fix tests using assert_raise_with_message on US-ASCII systems</title>
<updated>2025-08-16T02:42:07+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2025-08-16T01:15:45+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=87c4ebd00115b9424f04813b4dd5f3d087a14eb9'/>
<id>87c4ebd00115b9424f04813b4dd5f3d087a14eb9</id>
<content type='text'>
On systems where the Encoding.default_internal defaults to US-ASCII instead
of UTF-8, some tests using assert_raise_with_message can fail since it no
longer changes Encoding.default_internal in 79f5202.

This tests explicitly uses EnvUtil.with_default_internal on systems where
these tests fail.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
On systems where the Encoding.default_internal defaults to US-ASCII instead
of UTF-8, some tests using assert_raise_with_message can fail since it no
longer changes Encoding.default_internal in 79f5202.

This tests explicitly uses EnvUtil.with_default_internal on systems where
these tests fail.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix `Integer.sqrt` to never exceed actual value</title>
<updated>2025-04-07T02:08:10+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2025-04-06T09:36:06+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=3a7b9ca93b91dcc086b9ac8b9957e59268f9493b'/>
<id>3a7b9ca93b91dcc086b9ac8b9957e59268f9493b</id>
<content type='text'>
`Integer.sqrt` uses `sqrt(3)` from libm for small values.
This method must return a value less than or equal to the actual integer
square root, but libm's sqrt does not always guarantee that.

This change corrects that by decrementing the result if necessary.

Fixes [Bug #21217]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
`Integer.sqrt` uses `sqrt(3)` from libm for small values.
This method must return a value less than or equal to the actual integer
square root, but libm's sqrt does not always guarantee that.

This change corrects that by decrementing the result if necessary.

Fixes [Bug #21217]
</pre>
</div>
</content>
</entry>
<entry>
<title>Avoid calculating large powers</title>
<updated>2024-11-08T11:53:21+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2024-11-08T11:53:21+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=fde6d189b23a5d471d212509ab1a6609718c74fe'/>
<id>fde6d189b23a5d471d212509ab1a6609718c74fe</id>
<content type='text'>
... for slow CI machines like macOS.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
... for slow CI machines like macOS.
</pre>
</div>
</content>
</entry>
<entry>
<title>Do not round `a**b` to infinity</title>
<updated>2024-11-08T10:48:56+00:00</updated>
<author>
<name>Yusuke Endoh</name>
<email>mame@ruby-lang.org</email>
</author>
<published>2024-11-08T05:46:35+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=45cd4a8296814f3b082dfb906cdef29974726731'/>
<id>45cd4a8296814f3b082dfb906cdef29974726731</id>
<content type='text'>
... 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]
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
... 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]
</pre>
</div>
</content>
</entry>
<entry>
<title>Move incorrectly placed tests</title>
<updated>2024-07-30T13:02:23+00:00</updated>
<author>
<name>Peter Zhu</name>
<email>peter@peterzhu.ca</email>
</author>
<published>2024-07-30T13:02:23+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=b37ffb93457d6ad68685c53abfd4f7338e773dac'/>
<id>b37ffb93457d6ad68685c53abfd4f7338e773dac</id>
<content type='text'>
The tests for Integer#ceil was accidentally placed in test_truncate.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The tests for Integer#ceil was accidentally placed in test_truncate.
</pre>
</div>
</content>
</entry>
<entry>
<title>Fix ceil when ndigits is large</title>
<updated>2024-07-30T12:21:28+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=a7167d0ceecc8eea7bdf87e66be16d16b0f417e7'/>
<id>a7167d0ceecc8eea7bdf87e66be16d16b0f417e7</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-07-30T12:21:28+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=3af2a7fbe12e11bac7b26bd991d3d02349f47295'/>
<id>3af2a7fbe12e11bac7b26bd991d3d02349f47295</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>Fix the return value of `Integer#downto` called with a block</title>
<updated>2024-07-04T03:11:12+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2024-07-04T01:19:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=0fe024d04845d2f8cac84f5009920b39212e964e'/>
<id>0fe024d04845d2f8cac84f5009920b39212e964e</id>
<content type='text'>
As the document states, it should return `self`, not `nil`.
Fix up of f4b313f7338f5fbe37f73aae29f70aeb474f7f5b.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
As the document states, it should return `self`, not `nil`.
Fix up of f4b313f7338f5fbe37f73aae29f70aeb474f7f5b.
</pre>
</div>
</content>
</entry>
<entry>
<title>[Bug #17037] Improve accuracy of division near precision limits</title>
<updated>2023-11-29T11:16:36+00:00</updated>
<author>
<name>Nobuyoshi Nakada</name>
<email>nobu@ruby-lang.org</email>
</author>
<published>2023-11-29T11:16:36+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=8e93bf8e1fbac73b677c333b19a8b55ae9daddc3'/>
<id>8e93bf8e1fbac73b677c333b19a8b55ae9daddc3</id>
<content type='text'>
When dividing near the precision limit of `double`, use Bignum
division to get rid of rounding errors.
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
When dividing near the precision limit of `double`, use Bignum
division to get rid of rounding errors.
</pre>
</div>
</content>
</entry>
<entry>
<title>Rewrite Integer#times in Ruby (#8388)</title>
<updated>2023-09-07T17:57:52+00:00</updated>
<author>
<name>Takashi Kokubun</name>
<email>takashikkbn@gmail.com</email>
</author>
<published>2023-09-07T17:57:52+00:00</published>
<link rel='alternate' type='text/html' href='https://git.ruby-lang.org/ruby.git/commit/?id=5b5ae3d9e064e17e2a7d8d21d739fcc62ae1075c'/>
<id>5b5ae3d9e064e17e2a7d8d21d739fcc62ae1075c</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
