Convert num from scientific notation to float
Posted: Thu Jul 13, 2006 11:43 am
How would I convert a number from 0.420049480000000E+02 format to a float or double?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
I believe this is correct. I was just wondering if there was a built-in function... the math isn't difficult, but I figured why reinvent the wheel? I'll just do the math I guess. Thanks man.pickle wrote:42.004948
You might want to test but even for dodgy string like 0.420049480000000E+02 i think this should work:The Ninja Space Goat wrote:How would I convert a number from 0.420049480000000E+02 format to a float or double?
Code: Select all
$var = '0.420049480000000E+02';
$floatVar = (float)$var;did it for me:The Ninja Space Goat wrote:no, (float) didn't do it... made it 0... and settype turned it into a 1. Any other suggestions?
Code: Select all
$var = '0.420049480000000E+02';
$floatVar = (float)$var;
var_dump(phpversion());
var_dump($floatVar);
// string(5) "5.1.2"
// float(42.004948)
// string(5) "4.4.2"
// float(42.004948)*SERIOUSLY* impressive. VERY cool.
Eh... and what does it do? Drawing curves on google maps?I DID IT!!!!
Outlines counties based on coordinate lists.Weirdan wrote:Eh... and what does it do? Drawing curves on google maps?I DID IT!!!!
Oh wow that is impressive. Not that hard though, I imagine.Outlines counties based on coordinate lists.