jQuery Float Number
I have problem with following calculation:
$result = $a + $b + ($c * $d - $e) * $f + $g;
The formula may more complicated. I found some variables are treated as
String instead of Number, therefore the result is wrong.
For the following code:
$result = parseFloat($a) + parseFloat($b) + (parseFloat($c) *
parseFloat($d) - parseFloat($e)) * parseFloat($f) + parseFloat($g);
It seems right. However, is there any good way to do it, instead of write
parseFloat() function for each of the variable?
No comments:
Post a Comment