I want this:
In website have var number = 0.33
and I want var second = fractions of variable 'number'
, and if "number" fractions change : second
will change.
But how?
Javascript Number() Function object: This parameter holds the objects that will be converted any type of javascript variable to number type. Return Values: Number() function returns the number format for any type of javascript variable. Example 2: Not a number is returned by the compiler.
JavaScript numbers are always stored as double precision floating point numbers, following the international IEEE 754 standard. This format stores numbers in 64 bits, where the number (the fraction) is stored in bits 0 to 51, the exponent in bits 52 to 62, and the sign in bit 63: Value (aka Fraction/Mantissa)
You can use Erik Garrison's fraction.js library to do that and more fractional operations.
var second = new Fraction(.033);
console.log(second.numerator + '/' + second.denominator);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With