Skip to content
  • Peter Zhu's avatar
    0922afa9
    [Bug #20654] Fix floor and ceil when ndigits is large (#11277) · 0922afa9
    Peter Zhu authored
    * 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.
    0922afa9
    [Bug #20654] Fix floor and ceil when ndigits is large (#11277)
    Peter Zhu authored
    * 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.
Loading