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

53 lines
1.5 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
The math library includes math related functions that you can use with [Numbers](/microbit/reference/types/number).
* In the [Block editor](/microbit/blocks/editor), click **maths** on the left to see the available blocks
The functions available in Block Editor are:
### abs
math `->` abs (x : [Number](/microbit/reference/types/number)) *returns* [Number](/microbit/reference/types/number)
returns the absolute value of input parameter `x`
![](/static/mb/blocks/math-0.png)
### max
math `->` max (x : [Number](/microbit/reference/types/number), y : [Number](/microbit/reference/types/number)) *returns* [Number](/microbit/reference/types/number)
returns the larger of two input numbers (`x` and `y`)
![](/static/mb/blocks/math-1.png)
### min
math `->` min (x : [Number](/microbit/reference/types/number), y : [Number](/microbit/reference/types/number)) *returns* [Number](/microbit/reference/types/number)
returns the smaller of two input numbers (`x` and `y`)
![](/static/mb/blocks/math-2.png)
### random
math `->` random (limit : [Number](/microbit/reference/types/number)) *returns* [Number](/microbit/reference/types/number)
returns a random [Number](/microbit/reference/types/number) between 0 and the parameter *limit*
![](/static/mb/blocks/math-3.png)
### Lessons
[love meter](/microbit/lessons/love-meter)
### See also
[Block Editor documentation](/microbit/blocks/contents), [Number](/microbit/reference/types/number)