Math

Math related functions and extended versions of normal Math functions.

Functions

Util.random

Definition

Name
Util.random
Shorthand
u.random
Syntax
Number = Util.random( Number min, Number max );

Description

Generate a random number between min and max (both included).

Parameters

min
Number The min number that can be returned
max
Number The max number that can be returned

Return values

A random number from the given min/max range

Examples

u.random(1,10);

returns Number between 1 and 10. Both included.

Dependencies

JavaScript
  • Math.round
  • Math.random
Manipulator

none

Util.round

Definition

Name
Util.round
Syntax
Number = Util.round( Number number, Integer decimals );

Description

Round number to decimals

Parameters

number
Number number to round

Return values

Number rounded number

Examples

Util.round(0.1234567, 5);

returns Number 0.12346

Dependencies

JavaScript
  • Math.pow
  • Math.round
Manipulator

None

Util.numToHex

Definition

Name
Util.numToHex
Syntax
Hex = Util.numToHex( Number num );

Description

Convert num to Hex value

Parameters

num
Number number to convert to Hex

Return values

Hex hex value of number

Examples

Util.numToHex(255);

returns String ff

Util.numToHex(47);

returns String 2f

Dependencies

JavaScript
  • Number.toString
Manipulator

None

Util.hexToNum

Definition

Name
Util.hexToNum
Syntax
Number = Util.hexToNum( Hex hex );

Description

Convert hex to Numeric value

Parameters

hex
Hex hex to convert to number

Return values

Number Numeric value of Hex

Examples

Util.hexToNum("ff");

returns String 255

Util.hexToNum("2f");

returns String 47

Dependencies

JavaScript
  • parseInt
Manipulator

None

Files

Main file

  • u-math.js

Segment support files

  • none

Segment dependencies

desktop_edge
u-math.js
desktop_ie11
u-math.js
desktop
u-math.js
desktop_ie10
u-math.js
desktop_ie9
u-math.js
desktop_light
u-math.js
tablet
u-math.js
tablet_light
u-math.js
smartphone
u-math.js
mobile
not tested
mobile_light
not tested
tv
u-math.js
seo
not supported