Commit 0922afa
authored
[Bug #20654] Fix floor and ceil when ndigits is large (ruby#11277)
* Fix floor when ndigits is large
[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) # => -100000
puts -1.floor(-10) # => -10000000000
puts -1.floor(-20) # => 0
This commit changes the last result so that it will return
-100000000000000000000.
* Fix ceil when ndigits is large
[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) # => 100000
puts 1.ceil(-10) # => 10000000000
puts 1.ceil(-20) # => 0
This commit changes the last result so that it will return
100000000000000000000.1 parent ce565cd commit 0922afa
3 files changed
+33
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2373 | 2373 | | |
2374 | 2374 | | |
2375 | 2375 | | |
2376 | | - | |
2377 | | - | |
2378 | | - | |
2379 | | - | |
2380 | | - | |
| 2376 | + | |
2381 | 2377 | | |
2382 | 2378 | | |
2383 | 2379 | | |
| |||
2386 | 2382 | | |
2387 | 2383 | | |
2388 | 2384 | | |
2389 | | - | |
2390 | | - | |
2391 | | - | |
| 2385 | + | |
| 2386 | + | |
| 2387 | + | |
| 2388 | + | |
| 2389 | + | |
| 2390 | + | |
2392 | 2391 | | |
2393 | | - | |
2394 | 2392 | | |
2395 | 2393 | | |
2396 | 2394 | | |
2397 | 2395 | | |
2398 | 2396 | | |
2399 | | - | |
2400 | | - | |
2401 | | - | |
2402 | | - | |
2403 | | - | |
| 2397 | + | |
2404 | 2398 | | |
2405 | 2399 | | |
2406 | 2400 | | |
| |||
2410 | 2404 | | |
2411 | 2405 | | |
2412 | 2406 | | |
2413 | | - | |
2414 | | - | |
2415 | | - | |
| 2407 | + | |
| 2408 | + | |
| 2409 | + | |
| 2410 | + | |
| 2411 | + | |
| 2412 | + | |
| 2413 | + | |
| 2414 | + | |
| 2415 | + | |
2416 | 2416 | | |
2417 | | - | |
2418 | 2417 | | |
2419 | 2418 | | |
2420 | 2419 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
533 | 537 | | |
534 | 538 | | |
535 | 539 | | |
| |||
557 | 561 | | |
558 | 562 | | |
559 | 563 | | |
| 564 | + | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
560 | 568 | | |
561 | 569 | | |
562 | 570 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
468 | 472 | | |
469 | 473 | | |
470 | 474 | | |
| |||
493 | 497 | | |
494 | 498 | | |
495 | 499 | | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
496 | 504 | | |
497 | 505 | | |
498 | 506 | | |
| |||
0 commit comments