Math

Standard JavaScript Math library plus embedded extensions: Math.map() scaling and a hardware random number generator.

The standard JavaScript Math library is available, with two embedded specialties documented below: Math.map() for scaling sensor values and Math.random() backed by the hardware random number generator.

Constants: Math.E (≈2.718), Math.LN10 (≈2.303), Math.LN2 (≈0.693), Math.LOG10E (≈0.434), Math.LOG2E (≈1.443), Math.PI (≈3.14159), Math.SQRT1_2 (≈0.707), Math.SQRT2 (≈1.414).

Standard methods: abs, acos, acosh, asin, asinh, atan, atan2, atanh, cbrt, ceil, cos, cosh, exp, floor, log, max, min, pow, round, sin, sinh, sqrt, tan, tanh, trunc — all behave as in standard JavaScript.

Functions

Math.random()

Math.random() → number

Returns a 32-bit random number from the hardware random number generator.

Unlike standard JavaScript, Math.random() on the Q5C is backed by the hardware random number generator, making it suitable for nonces and keys.

Returns

number 32-bit hardware random number.

Example

let nonce = Math.random();