Ruby Numbers
Integers have no size limit. Math methods: abs, round, floor, ceil, divmod, pow and Math.sqrt. Integer division truncates, and Float division needs a float.
Example
puts 2 ** 100
puts 17.divmod(5).inspect
puts 3.14159.round(2), 7.5.floor, 7.2.ceil
puts Math.sqrt(81), 10.fdiv(4)
puts 1_000_000 + 1Result
1267650600228229401496703205376 [3, 2] 3.14 7 8 9.0 2.5 1000001
Exercise
Quotient and remainder.
17.(5)
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.