I have a javascript function that converts feet into a usable object that will take the total feet and break it down into feet / inch / fraction.
In the example below the decimal fraction portion should be zero and my inch should be 4
Lets say I've got the following.
var inches = 40;
Now when I call the function below like so unPackDecimalFeet(40 /12);
unPackDecimalFeet: function (feetInchFraction) {
var inchFraction = (feetInchFraction - ~~feetInchFraction) * 12;
return {
feet: ~~feetInchFraction,
inch: ~~inchFraction,
fraction: inchFraction - ~~inchFraction
};
}
My return value is below.
feet: 3
fraction: 0.9999999999999964
inch: 3
**The above return value should read.
feet: 3
fraction: 0
inch: 4
How would I need to process the feet so that I can get the correct return value?