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.
the value that the fractional part should be returned for.
// Example
alert("12.354 = " + Math.TA_frac(12.345));
Convert an integer to a Roman numeral. Returns the number as a roman numeral string.
the number to convert.
defaults to true
and will output as upper case, otherwise as lower case.
// Example
alert(Math.TA_integerToRoman(2021, false));
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
.
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));
Math (Native)
The ThoughtAsylum library includes a set of extensions to the standard Math object.