pxt-calliope/docs/blocks/math.md

37 lines
332 B
Markdown
Raw Normal View History

2016-04-06 08:11:48 +02:00
# Math
2016-09-01 15:49:39 +02:00
### [Numeric](/reference/types/number) values: 0, 1, 2, ...
2016-04-06 08:11:48 +02:00
2016-09-01 15:49:39 +02:00
```block
2016-04-06 08:11:48 +02:00
0;
1;
2;
```
2016-09-01 15:49:39 +02:00
### Arithmetic binary operation (+, -, *, /)
2016-04-06 08:11:48 +02:00
2016-09-01 15:49:39 +02:00
```block
2016-04-06 08:11:48 +02:00
0+1;
0-1;
1*2;
3/4;
```
2016-09-01 15:49:39 +02:00
### Absolute value
2016-04-06 08:11:48 +02:00
2016-09-01 15:49:39 +02:00
```block
2016-04-06 08:11:48 +02:00
Math.abs(-5);
```
2016-09-01 15:49:39 +02:00
### Minimum/maximum of two values
2016-04-06 08:11:48 +02:00
2016-09-01 15:49:39 +02:00
```block
2016-04-06 08:11:48 +02:00
Math.min(0, 1);
```
2016-09-01 15:49:39 +02:00
### Random value
2016-04-06 08:11:48 +02:00
2016-09-01 15:49:39 +02:00
```block
2016-04-06 08:11:48 +02:00
Math.random(5);
```