2
2

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 5 years have passed since last update.

変数:variableに関して

2
Last updated at Posted at 2015-07-28

変数とはデータの入れ物
変数名 = 値で変数に代入することが出来る

name = "Qiita"
puts name

results 

# => Qiita

実際にやってみる 割り算「/」に関して


商を求める(小数点以下を気にしない)

number_1 = 654321
number_2 = 123456  

puts number_1/number_2

result

# => 5

浮動小数点数を求める

number_1 = 654321
number_2 = 123456  

p number_1.to_f/number_2

result

# => 5.300034020217729

分数を求める

number_1 = 654321
number_2 = 123456  

p number_1.quo(123456) 

result
# => (218107/41152)

参考サイト
http://qiita.com/cia_rana/items/525ed5a57a28aaf9d2eb
http://ai-future.hatenablog.jp/entry/%E3%83%8B%E3%83%BC%E3%83%88%E5%B0%B1%E8%81%B7

2
2
2

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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?