ultrus Posted August 19, 2008 Share Posted August 19, 2008 Hello, I'm playing around with the Yale Bright Star Catalog, thinking of the best way to convert the E notation provided into decimal numbers. I know how to do it the hard way by parsing the string and doing the math. Is there a pre-built function for this though?: -9.7205E-01 = -.97205 2.3496E+01= 23.496 -1.3808E+01 = -13.808 Thanks for the feedback. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 19, 2008 Share Posted August 19, 2008 echo rtrim(sprintf("%f", -9.7205E-01),"0") . "<br />"; echo rtrim(sprintf("%f", 2.3496E+01),"0") . "<br />"; echo rtrim(sprintf("%f", -1.3808E+01),"0") . "<br />"; Quote Link to comment Share on other sites More sharing options...
ultrus Posted August 19, 2008 Author Share Posted August 19, 2008 PFMaBiSmAd, You the man! That helps simplify things a lot. A have to parse a file with over 28,000 of those, and that should save some time. Thank you, Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted August 19, 2008 Share Posted August 19, 2008 The number of course can be in a variable, so a loop could be used. Quote Link to comment Share on other sites More sharing options...
ultrus Posted August 19, 2008 Author Share Posted August 19, 2008 Yep yep. I plan on looping through each line of a file, getting and converting numbers, and adding to a database. I could just imagine the pain involved in converting each number one at a time. ouch! Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.