Options
All
• Public
• Public/Protected
• All

# Math (Native)

The ThoughtAsylum library includes a set of extensions to the standard Math object.

• Math

## Methods

### TA_frac

• TA_frac(p_numValue: number): number
• Get the fractional part of a number. JavaScript frustratingly does imperfect calculations with decimals, and so this function jumps through some hoops to give a higher precision answer than the JavaScript mathematics functions alone might provide. e.g. try `alert(12.345 - Math.floor(12.345));` and check the result! The function accounts for differing separators between locales, zero values, negative values, and values missing leading zeros.

#### Parameters

• ##### p_numValue: number

the value that the fractional part should be returned for.

``````// Example

### TA_isOneIn

• TA_isOneIn(p_intMax: number): Boolean
• For a random integer up to the one specified returns `true` if the number generated is a one. The idea is to return `true`/`false` on the chance of something occurring being one in, and the number specified. The function generates an integer between one and the specified maximum value, inclusive, and if the result is `1` it will return `true`, otherwise it returns `false`.

#### Parameters

• ##### p_intMax: number

the maximum value of the random integer the function will generate.

``````// Example

### TA_randInt

• TA_randInt(p_intMin: number, p_intMax: number): number
• Generate a random integer value between a minimum and maximum value (inclusive). Parameters should be integers and will be rounded down if not.

#### Parameters

• ##### p_intMin: number

minimum value of the random integer.

• ##### p_intMax: number

maximum value of the random integer.

``````// Example