Fetching contributors…
Cannot retrieve contributors at this time
87 lines (64 sloc) 2.06 KB

# 练习3. 数字和数学计算

• + plus 加号
• - minus 减号
• / slash 斜杠 除法
• * asterisk 星号 乘法
• % percent 百分号 模除
• < less-than 小于号
• > greater-than 大于号
• <= less-than-equal 小于等于号
• >= greater-than-equal 大于等于号

``````"I will now count my chickens:" println

"Hens " print .. (25 + 30 / 6) println
"Roosters " print .. (100 - 25 * 3 % 4) println

"Now I will count the eggs:" println

(3 + 2 + 1 - 5 + 4 % 2 - 1 + 6) println

"Is it true that 3 + 2 < 5 - 7?" println

(3 + 2 < 5 - 7) println

"What is 3 + 2? " print .. (3 + 2) println
"What is 5 - 7? " print .. (5 - 7) println

"Oh, that's why it's False." println

"How about some more." println

"Is it greater? " print .. (5 > -2) println
"Is it greater or equal? " print .. (5 >= -2) println
"Is it less or equal? " print .. (5 <= -2) println

``````

## 你看到的结果

``````> io ex3.io
I will now count my chickens:
Hens 30
Roosters 97
Now I will count the eggs:
6
Is it true that 3 + 2 < 5 - 7?
false
What is 3 + 2? 5
What is 5 - 7? -2
Oh, that's why it's False.
How about some more.
Is it greater? true
Is it greater or equal? true
Is it less or equal? false
``````

## 有效的数字格式:

``````123
123.456
0.456
.456
123e-4
123e4
123.456e-7
123.456e2
``````

## 十六进制数也支持(不限大小写):

``````0x0
0x0F
0XeE
``````
You can’t perform that action at this time.