The mJS is a restricted JavaScript engine designed for microcontrollers with limited resources. The Math object is not supported out of the box to limit the library footprint.
This library adds some of the JavaScript Math object properties and methods.
Import library in mos.yml
:
libs:
- origin: https://github.com/mongoose-os-libs/mjs
- origin: https://github.com/Dietatko/mjs-math
Use in javascript code:
load("mjs_math.js");
Following functions are available:
- Infinity
- Number.EPSILON
- Number.NaN
- Number.isNaN
- Number.NEGATIVE_INFINITY
- Number.POSITIVE_INFINITY
- Number.isFinite
- Math.E
- Math.LN10
- Math.LN2
- Math.LOG10E
- Math.LOG2E
- Math.PI
- Math.SQRT1_2
- Math.SQRT2
- Math.abs
- Math.exp
- Math.log
- Math.log10
- Math.log2
- Math.pow
Not all functions are available to limit amount of storage and memory needed. There is no option of including only some of the functions at the moment.