PJ droopy pants Posted February 9, 2009 Share Posted February 9, 2009 For instanse if someone was to put in a number into one of my forms like 1.0497330552348E+16. I am using $amount = (floor($_POST['amount'])); but it does not round that type of number down. Please any help would be great. Quote Link to comment https://forums.phpfreaks.com/topic/144415-solved-function-to-remove-e/ Share on other sites More sharing options...
PJ droopy pants Posted February 9, 2009 Author Share Posted February 9, 2009 I got it. $amount = preg_replace("/[[:^digit:]]/", '', $amount); Quote Link to comment https://forums.phpfreaks.com/topic/144415-solved-function-to-remove-e/#findComment-757848 Share on other sites More sharing options...
Mark Baker Posted February 9, 2009 Share Posted February 9, 2009 Solved by simply removing the 'E' ? ? ? ? Learn some basic mathematics. Try running the following, and tell me which method actually displays the correct value. $iString = '1.0497330552348E+16'; $iFloat1 = (float) $iString; $iFloat2 = (float) preg_replace("/[[:^digit:]]/", '', $iString); echo 'First Method gives '.number_format($iFloat1).'<br />'; echo 'Second Method gives '.number_format($iFloat2).'<br />'; Quote Link to comment https://forums.phpfreaks.com/topic/144415-solved-function-to-remove-e/#findComment-758543 Share on other sites More sharing options...
Daniel0 Posted February 11, 2009 Share Posted February 11, 2009 http://en.wikipedia.org/wiki/Scientific_notation#E_notation Quote Link to comment https://forums.phpfreaks.com/topic/144415-solved-function-to-remove-e/#findComment-759943 Share on other sites More sharing options...
marcus Posted February 12, 2009 Share Posted February 12, 2009 Or you could use http://www.php.net/manual/en/ref.bc.php for large integers. Quote Link to comment https://forums.phpfreaks.com/topic/144415-solved-function-to-remove-e/#findComment-760708 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.