Cagri Posted July 8, 2009 Share Posted July 8, 2009 Hello, in PHP when i calculate big numbers, result is something like that : "1.9753086024691E+15" i want print all digits not with E+XX i looked at the PHP:BC Math Manual but i didn't understand. how can i fix it? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/165230-php-calculation-question/ Share on other sites More sharing options...
corbin Posted July 8, 2009 Share Posted July 8, 2009 What's not to understand? The BCMath functions are extremely straight forward. You just use them in place of operators like + - * /, and you get a string returned instead of an int or float. Quote Link to comment https://forums.phpfreaks.com/topic/165230-php-calculation-question/#findComment-871312 Share on other sites More sharing options...
Daniel0 Posted July 8, 2009 Share Posted July 8, 2009 You can also just use sprintf to get it in another formatting. Like sprintf('%d', $largeInteger); Quote Link to comment https://forums.phpfreaks.com/topic/165230-php-calculation-question/#findComment-871315 Share on other sites More sharing options...
rhodesa Posted July 8, 2009 Share Posted July 8, 2009 The value is there, but when you print/echo something, it forces it to a string first. If you use the number_format() function, you will see the whole thing: <?php $num = pow(1234567890,5); echo number_format($num); ?> Quote Link to comment https://forums.phpfreaks.com/topic/165230-php-calculation-question/#findComment-871317 Share on other sites More sharing options...
corbin Posted July 8, 2009 Share Posted July 8, 2009 You can also just use sprintf to get it in another formatting. Like sprintf('%d', $largeInteger); Oh yeah.... I didn't think about sprintf. Yeah, I didn't think about number_format either. I'm sure doing the math normally then using number_format is faster than bcpow. Quote Link to comment https://forums.phpfreaks.com/topic/165230-php-calculation-question/#findComment-871328 Share on other sites More sharing options...
Daniel0 Posted July 8, 2009 Share Posted July 8, 2009 It depends on how large your integers are or how much precision you need on your floats. Quote Link to comment https://forums.phpfreaks.com/topic/165230-php-calculation-question/#findComment-871332 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.