0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Ruby学習#9 Math & Numbers

Posted at

9 Math & Numbers

puts 5

5
puts 5.76554
5.76554
puts -5.76554
-5.76554

puts 5 + 9

14

puts 2 ** 3

8

puts 10 % 3

1

num = 20
puts ("my fav num " + num)
puts ("my fav num " + num.to_s)

my fav num 20

num = -20
puts num.abs()

20
num = 20.487
puts num.round()
20
num = 20.687
puts num.round()
21

切り上げ ceil()
num = 20.1
puts num.ceil()

21

切り下げ floor()
num = 20.9
puts num.floor()

num = 20.9
puts Math.sqrt()
puts Math.sqrt(36)

6
puts Math.log(1)
0.0

puts 1 + 7

8
puts 1.0 + 7
8.0
puts 10 / 7
1

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?