* [ruby-core:118699] [Ruby master Bug#20654] Floor and ceil have unexpected behaviour when ndigits is large
@ 2024-07-26 15:19 peterzhu2118 (Peter Zhu) via ruby-core
2024-07-30 13:17 ` [ruby-core:118741] " peterzhu2118 (Peter Zhu) via ruby-core
2024-08-18 2:03 ` [ruby-core:118869] " nagachika (Tomoyuki Chikanaga) via ruby-core
0 siblings, 2 replies; 3+ messages in thread
From: peterzhu2118 (Peter Zhu) via ruby-core @ 2024-07-26 15:19 UTC (permalink / raw)
To: ruby-core; +Cc: peterzhu2118 (Peter Zhu)
Issue #20654 has been reported by peterzhu2118 (Peter Zhu).
----------------------------------------
Bug #20654: Floor and ceil have unexpected behaviour when ndigits is large
https://bugs.ruby-lang.org/issues/20654
* Author: peterzhu2118 (Peter Zhu)
* Status: Open
* Backport: 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: REQUIRED
----------------------------------------
GitHub PR: https://github.com/ruby/ruby/pull/11257
There is unexpected behaviour in Integer#floor, Float#floor, Integer#ceil, Float#ceil when 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:
```ruby
puts -1.floor(-5) # => -100000
puts -1.floor(-10) # => -10000000000
puts -1.floor(-20) # => 0
```
```ruby
puts 1.ceil(-5) # => 100000
puts 1.ceil(-10) # => 10000000000
puts 1.ceil(-20) # => 0
```
The PR changes the last result so that it will return -100000000000000000000 and 100000000000000000000, respectively.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:118741] [Ruby master Bug#20654] Floor and ceil have unexpected behaviour when ndigits is large
2024-07-26 15:19 [ruby-core:118699] [Ruby master Bug#20654] Floor and ceil have unexpected behaviour when ndigits is large peterzhu2118 (Peter Zhu) via ruby-core
@ 2024-07-30 13:17 ` peterzhu2118 (Peter Zhu) via ruby-core
2024-08-18 2:03 ` [ruby-core:118869] " nagachika (Tomoyuki Chikanaga) via ruby-core
1 sibling, 0 replies; 3+ messages in thread
From: peterzhu2118 (Peter Zhu) via ruby-core @ 2024-07-30 13:17 UTC (permalink / raw)
To: ruby-core; +Cc: peterzhu2118 (Peter Zhu)
Issue #20654 has been updated by peterzhu2118 (Peter Zhu).
I opened backport PRs.
3.3: https://github.com/ruby/ruby/pull/11277
3.2: https://github.com/ruby/ruby/pull/11278
----------------------------------------
Bug #20654: Floor and ceil have unexpected behaviour when ndigits is large
https://bugs.ruby-lang.org/issues/20654#change-109280
* Author: peterzhu2118 (Peter Zhu)
* Status: Closed
* Backport: 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: REQUIRED
----------------------------------------
GitHub PR: https://github.com/ruby/ruby/pull/11257
There is unexpected behaviour in Integer#floor, Float#floor, Integer#ceil, Float#ceil when 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:
```ruby
puts -1.floor(-5) # => -100000
puts -1.floor(-10) # => -10000000000
puts -1.floor(-20) # => 0
```
```ruby
puts 1.ceil(-5) # => 100000
puts 1.ceil(-10) # => 10000000000
puts 1.ceil(-20) # => 0
```
The PR changes the last result so that it will return -100000000000000000000 and 100000000000000000000, respectively.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
* [ruby-core:118869] [Ruby master Bug#20654] Floor and ceil have unexpected behaviour when ndigits is large
2024-07-26 15:19 [ruby-core:118699] [Ruby master Bug#20654] Floor and ceil have unexpected behaviour when ndigits is large peterzhu2118 (Peter Zhu) via ruby-core
2024-07-30 13:17 ` [ruby-core:118741] " peterzhu2118 (Peter Zhu) via ruby-core
@ 2024-08-18 2:03 ` nagachika (Tomoyuki Chikanaga) via ruby-core
1 sibling, 0 replies; 3+ messages in thread
From: nagachika (Tomoyuki Chikanaga) via ruby-core @ 2024-08-18 2:03 UTC (permalink / raw)
To: ruby-core; +Cc: nagachika (Tomoyuki Chikanaga)
Issue #20654 has been updated by nagachika (Tomoyuki Chikanaga).
Backport changed from 3.1: UNKNOWN, 3.2: REQUIRED, 3.3: REQUIRED to 3.1: UNKNOWN, 3.2: DONE, 3.3: DONE
Thank you for preparing the backport PRs. They were merged.
----------------------------------------
Bug #20654: Floor and ceil have unexpected behaviour when ndigits is large
https://bugs.ruby-lang.org/issues/20654#change-109441
* Author: peterzhu2118 (Peter Zhu)
* Status: Closed
* Backport: 3.1: UNKNOWN, 3.2: DONE, 3.3: DONE
----------------------------------------
GitHub PR: https://github.com/ruby/ruby/pull/11257
There is unexpected behaviour in Integer#floor, Float#floor, Integer#ceil, Float#ceil when 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:
```ruby
puts -1.floor(-5) # => -100000
puts -1.floor(-10) # => -10000000000
puts -1.floor(-20) # => 0
```
```ruby
puts 1.ceil(-5) # => 100000
puts 1.ceil(-10) # => 10000000000
puts 1.ceil(-20) # => 0
```
The PR changes the last result so that it will return -100000000000000000000 and 100000000000000000000, respectively.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-18 2:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-26 15:19 [ruby-core:118699] [Ruby master Bug#20654] Floor and ceil have unexpected behaviour when ndigits is large peterzhu2118 (Peter Zhu) via ruby-core
2024-07-30 13:17 ` [ruby-core:118741] " peterzhu2118 (Peter Zhu) via ruby-core
2024-08-18 2:03 ` [ruby-core:118869] " nagachika (Tomoyuki Chikanaga) via ruby-core
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).