The ThoughtAsylum library includes a set of extensions to the standard Math object.
Get the fractional part of a number.
function jumps through some hoops to give a higher precision answer than the
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.
the value that the fractional part should be returned for.
// Example alert("12.354 = " + Math.TA_frac(12.345));
For a random integer up to the one specified returns
true if the number generated is a one.
The idea is to return
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
the maximum value of the random integer the function will generate.
// Example alert(Math.TA_isOneIn(6));
Generate a random integer value between a minimum and maximum value (inclusive). Parameters should be integers and will be rounded down if not.
minimum value of the random integer.
maximum value of the random integer.
// Example alert(Math.TA_randInt(1, 10));