[RUBY] About numerical values

Numerical value

** Numbers are values that represent numbers. Unlike character strings, calculations etc. You can do it. ** **

Numbers are different from strings, such as ** double quotes "</ font> ** ** You don't even need single quotes' </ font> **. The following is an example of how to represent numbers using numbers.

[Example] Ruby file


#integer
10

#Negative value
-10

#Decimal
3.14

If you enclose a number in double quotes, it will be treated as a string instead of a number. In programming, the string "10" and the number 10 are different. Numerical values can be calculated, but strings cannot.

Let's run the following code in irb

Let's write a Ruby number in irb and execute it.

irb


#Write a number and execute with the enter key
irb(main):001:0> 12345

#If it continues to be displayed like this, it is successful
=> 12345

Summary

** A number is a value that represents a number. ** **

that's all.

Recommended Posts