pxt-calliope/docs/reference/math/math.md

49 lines
1.3 KiB
Markdown
Raw Normal View History

2016-03-26 00:47:20 +01:00
# Math Library
2016-04-02 01:22:47 +02:00
Functions in the math library.
2016-03-26 00:47:20 +01:00
### @parent blocks/language
2016-04-13 17:27:45 +02:00
The math library includes math related functions that you can use with [Numbers](/reference/types/number).
2016-03-26 00:47:20 +01:00
2016-04-13 17:27:45 +02:00
* In the [Block editor](/blocks/editor), click **maths** on the left to see the available blocks
2016-03-26 00:47:20 +01:00
The functions available in Block Editor are:
### abs
2016-04-13 17:27:45 +02:00
math `->` abs (x : [Number](/reference/types/number)) *returns* [Number](/reference/types/number)
2016-03-26 00:47:20 +01:00
returns the absolute value of input parameter `x`
![](/static/mb/blocks/math-0.png)
### max
2016-04-13 17:27:45 +02:00
math `->` max (x : [Number](/reference/types/number), y : [Number](/reference/types/number)) *returns* [Number](/reference/types/number)
2016-03-26 00:47:20 +01:00
returns the larger of two input numbers (`x` and `y`)
![](/static/mb/blocks/math-1.png)
### min
2016-04-13 17:27:45 +02:00
math `->` min (x : [Number](/reference/types/number), y : [Number](/reference/types/number)) *returns* [Number](/reference/types/number)
2016-03-26 00:47:20 +01:00
returns the smaller of two input numbers (`x` and `y`)
![](/static/mb/blocks/math-2.png)
### random
2016-04-13 17:27:45 +02:00
math `->` random (limit : [Number](/reference/types/number)) *returns* [Number](/reference/types/number)
2016-03-26 00:47:20 +01:00
2016-04-13 17:27:45 +02:00
returns a random [Number](/reference/types/number) between 0 and the parameter *limit*
2016-03-26 00:47:20 +01:00
![](/static/mb/blocks/math-3.png)
### See also
2016-04-13 17:27:45 +02:00
[Block Editor documentation](/blocks/contents), [Number](/reference/types/number)
2016-03-26 00:47:20 +01:00