E
Eric Gibson
I could have sworn this would be a FAQ, but it doesn't appear to be in
there. You must get this all the time, or I'm just totally doing something
wrong.
Math with int's and floats appears to just not work at all, much to my
frustration. :-( I'm trying to write a simple calculation and it just plain
outputs wrong information. Something like this:
function calculateValue(kWh) {
dollar_amount = kWh * .033;
// dollar_amount = StrS(dollar_amount, 1, 2);
result.innerHTML = dollar_amount;
}
I even jumped through hoops to try to enforce type, and convert strings to
float format, but it still doesn't work (which is wierd in itself).
function calculateValue(inputValue) {
var kWh = new String(inputValue);
kWh = parseFloat(kWh);
dollar_amount = kWh * .033;
dollar_amount = StrS(dollar_amount, 1, 2);
result.innerHTML = dollar_amount;
}
I've seen float errors in calculators, and other languages, but nothing that
was just totally wrong everytime by a power of ~10, it's a little insane!
Eric
there. You must get this all the time, or I'm just totally doing something
wrong.
Math with int's and floats appears to just not work at all, much to my
frustration. :-( I'm trying to write a simple calculation and it just plain
outputs wrong information. Something like this:
function calculateValue(kWh) {
dollar_amount = kWh * .033;
// dollar_amount = StrS(dollar_amount, 1, 2);
result.innerHTML = dollar_amount;
}
I even jumped through hoops to try to enforce type, and convert strings to
float format, but it still doesn't work (which is wierd in itself).
function calculateValue(inputValue) {
var kWh = new String(inputValue);
kWh = parseFloat(kWh);
dollar_amount = kWh * .033;
dollar_amount = StrS(dollar_amount, 1, 2);
result.innerHTML = dollar_amount;
}
I've seen float errors in calculators, and other languages, but nothing that
was just totally wrong everytime by a power of ~10, it's a little insane!
Eric