xProteuSx Posted December 31, 2008 Share Posted December 31, 2008 Ok, here we go again! I have been trying to solve this for a while: I have a DB with a column full of numbers. Some of these numbers are very big and, when they are stored in the DB they are stored in the scientific notation format, such as 1000000=1e+06. I would like to take these numbers from a DB, and show them as integers. Right now if I do this: echo $numberfromdb; my output is '1e+06' If I try the following: $numberfromdb = 1e+06; $formattednumber = (int) $numberfromdb; echo $formattednumber; my output is '1' My quick solution was to change the DB column from 'float' type to 'bigint' type. However, I just realized that I have made a big boo-boo. I have several numbers which are fractions in decimal form (such as .50 and .25) and they have all been replaced with the number 1. Should be fun going back through 2300+ entries to fix this. Anyways, I am back to square one. How do I get 1e+06 to echo as 1000000??? Please help! This is very important and semi urgent. Quote Link to comment https://forums.phpfreaks.com/topic/139048-solved-scientific-notation-to-regular-integer/ Share on other sites More sharing options...
genericnumber1 Posted December 31, 2008 Share Posted December 31, 2008 Cast it to a double, float or real. <?php echo (double)'1e+06'; ?> Quote Link to comment https://forums.phpfreaks.com/topic/139048-solved-scientific-notation-to-regular-integer/#findComment-727245 Share on other sites More sharing options...
xProteuSx Posted December 31, 2008 Author Share Posted December 31, 2008 genericnumber1, Thanks so much. I can't believe I would get a working solution so fast! I have posted about this previously, and gotten many replies, but I could not get any of them to work. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/139048-solved-scientific-notation-to-regular-integer/#findComment-727262 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.