Ruby Learning # 9 Math & Numbers

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

Round up ceil () num = 20.1 puts num.ceil()

21

Rounded down 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

Recommended Posts

Ruby Learning # 9 Math & Numbers
Ruby learning 4
Ruby learning 5
Ruby learning 2
Ruby learning 6
Ruby learning 1
Ruby Learning # 25 Comments
Ruby Learning # 1 Introduction
Ruby Learning # 34 Modules
Ruby Learning # 33 Inheritance
Ruby Learning # 15 Methods
Safe numbers (ruby edition)
Ruby Learning # 30 Initialize Method
Ruby learning points (basic)
Ruby Learning # 29 Classes & Objects
Ruby Learning # 24 Exponent Method
Ruby Learning # 17 If Statements
Ruby Learning # 21 While Loops
Ruby Learning # 31 Object Methods
Ruby Learning # 27 Writing Files
Ruby Learning # 28 Handling Errors
Ruby Learning # 26 Reading Files
Ruby Learning # 23 For Loops
Ruby Learning # 16 Return Statement
Ruby Learning # 2 Drawing a Shape
Ruby on rails learning record -2020.10.03
Ruby on rails learning record -2020.10.04
Ruby on rails learning record -2020.10.09
Ruby Learning # 18 If Statements (Con't)
Ruby on Rails basic learning ①
Ruby Learning # 11 Building a Calculator
Ruby Learning # 99 Personal Programming Notebook
Ruby on rails learning record-2020.10.07 ②
Ruby Learning # 10 Getting User Input
Ruby Learning # 32 Building a Quiz
Ruby Learning # 8 Working With String
Ruby on rails learning record-2020.10.07 ①
Ruby on rails learning record -2020.10.06
[Ruby] Find numbers in arrays
Ruby Learning # 19 Building a Better Calculator
Completed Progate Ruby Learning Course II
Ruby Learning # 22 Building a Guessing Game
Learning Ruby with AtCoder 7 [Contest 168 Triple Dots]
Convert numbers to Roman numerals in Ruby
[Ruby] A program that determines prime numbers
Ruby Learning # 12 Building a Mad Libs Game
[Ruby] Express n-ary numbers as numbers starting from 0