Nuv Posted September 28, 2012 Share Posted September 28, 2012 When i am trying to do this simple math, php gives me rounded off result. $i = 44061410; $get_id = (2*$i + 76561197960265730) - 2; Expected Result - 76561198048388548 Result i am getting from php - 7.65611980484E+16 How can i see expected result ? Thankyou Quote Link to comment https://forums.phpfreaks.com/topic/268876-php-rounding-off-big-numbers/ Share on other sites More sharing options...
Barand Posted September 28, 2012 Share Posted September 28, 2012 try <?php $i = '44061410'; $j = '76561197960265730'; $res = bcsub (bcadd($j, bcmul($i, 2)) , 2) ; echo $res; //--> 76561198048388548 ?> Quote Link to comment https://forums.phpfreaks.com/topic/268876-php-rounding-off-big-numbers/#findComment-1381504 Share on other sites More sharing options...
silkfire Posted September 28, 2012 Share Posted September 28, 2012 For very big numbers its recommended to use the BCMath library, as Barand's example shows. Quote Link to comment https://forums.phpfreaks.com/topic/268876-php-rounding-off-big-numbers/#findComment-1381516 Share on other sites More sharing options...
Nuv Posted September 28, 2012 Author Share Posted September 28, 2012 Thankyou guys. Quote Link to comment https://forums.phpfreaks.com/topic/268876-php-rounding-off-big-numbers/#findComment-1381552 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.