情報学部 | 菅沼ホーム | 目次 | 索引 |
p (1.5).ceil # => 2 p (-1.5).ceil # => -1
p 2.coerce(1.5) # => [1.5, 2.0] p 2.coerce("1.5") # => [1.5, 2.0] p 1.5.coerce(2) # => [2.0, 1.5] p 1.5.coerce("2") # => [2.0, 1.5]
p 5.div(2.3) # => 2 p -5.div(2.3) # => -3 p 5.quo(2.3) # => 2.17391304347826 p -5.quo(2.3) # => -2.17391304347826
p 5.divmod(2) # => [2, 1] p -5.divmod(2) # => [-3, 1] p 5.divmod(-2) # => [-3, -1] p -5.divmod(-2) # => [2, -1]
p (1.5).floor # => 1 p (-1.5).floor # => -2
p 5.modulo(2) # => 1 p -5.modulo(2) # => 1 p 5.modulo(-2) # => -1 p -5.modulo(-2) # => -1 p 5.remainder(2) # => 1 p -5.remainder(2) # => -1 p 5.remainder(-2) # => 1 p -5.remainder(-2) # => -1
p 5.div(2.3) # => 2 p -5.div(2.3) # => -3 p 5.quo(2.3) # => 2.17391304347826 p -5.quo(2.3) # => -2.17391304347826
p 5.modulo(2) # => 1 p -5.modulo(2) # => 1 p 5.modulo(-2) # => -1 p -5.modulo(-2) # => -1 p 5.remainder(2) # => 1 p -5.remainder(2) # => -1 p 5.remainder(-2) # => 1 p -5.remainder(-2) # => -1
p (1.5).round # => 2 p (1.1).round # => 1 p (-1.1).round # => -1 p (-1.5).round # => -2
sum = 0 1.step(10, 1) { |n| sum += n } p sum # => 55 sum = 0 10.step(1, -1) { |n| sum += n } p sum # => 55
p (1.5).to_i # => 1 p (-1.5).to_i # => -1
情報学部 | 菅沼ホーム | 目次 | 索引 |