This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num1 = 3.1 | |
num2 = 6.5 | |
num3 = -1.2 | |
num4 = -4.5 | |
puts "変換前の数値はそれぞれ #{num1} #{num2} #{num3} #{num4} です。" | |
puts "切り捨て(to_i)の結果は、 #{num1.to_i} #{num2.to_i} #{num3.to_i} #{num4.to_i} です。" | |
puts "四捨五入(round)の結果は、 #{num1.round} #{num2.round} #{num3.round} #{num4.round} です。" | |
puts "切り上げ(ceil)の結果は、 #{num1.ceil} #{num2.ceil} #{num3.ceil} #{num4.ceil} です。" | |
puts "切り下げ(floor)の結果は、 #{num1.floor} #{num2.floor} #{num3.floor} #{num4.floor} です。" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment