stijn0713 Posted August 30, 2012 Share Posted August 30, 2012 bcpow(254, 187) % 319 gives me 210 while it should be 100. any reason? Quote Link to comment https://forums.phpfreaks.com/topic/267794-wrong-math-answer/ Share on other sites More sharing options...
Jessica Posted August 30, 2012 Share Posted August 30, 2012 What makes you think it should be 100? Quote Link to comment https://forums.phpfreaks.com/topic/267794-wrong-math-answer/#findComment-1373874 Share on other sites More sharing options...
xyph Posted August 30, 2012 Share Posted August 30, 2012 Why are you using the bc functions for one operation but not the other? Quote Link to comment https://forums.phpfreaks.com/topic/267794-wrong-math-answer/#findComment-1373956 Share on other sites More sharing options...
stijn0713 Posted August 30, 2012 Author Share Posted August 30, 2012 What makes you think it should be 100? i manually checked it... Quote Link to comment https://forums.phpfreaks.com/topic/267794-wrong-math-answer/#findComment-1374001 Share on other sites More sharing options...
stijn0713 Posted August 30, 2012 Author Share Posted August 30, 2012 for people interested: echo bcmod(bcpow(254,187),319) = 100 thank xyph Quote Link to comment https://forums.phpfreaks.com/topic/267794-wrong-math-answer/#findComment-1374004 Share on other sites More sharing options...
ignace Posted August 30, 2012 Share Posted August 30, 2012 Why are you using the bc functions for one operation but not the other? $r = bcmod(bcpow(254, 187), 319); // 100 Edit: damn 30 seconds late Edit: Actually echo bcmod(bcpow(254,187),319) = 100; Returns an error Quote Link to comment https://forums.phpfreaks.com/topic/267794-wrong-math-answer/#findComment-1374005 Share on other sites More sharing options...
Jessica Posted August 30, 2012 Share Posted August 30, 2012 Then I'd go with use the right function. <?php $pow = bcpow(254, 187); echo $pow.'<br>'; echo bcmod($pow, 319); ?> I got 100. Quote Link to comment https://forums.phpfreaks.com/topic/267794-wrong-math-answer/#findComment-1374006 Share on other sites More sharing options...
Ginge88 Posted June 20, 2013 Share Posted June 20, 2013 echo bcmod(bcpow(254,187),319) = 100;Returns an error No need for the = 100. echo bcmod(bcpow(254,187),319); Quote Link to comment https://forums.phpfreaks.com/topic/267794-wrong-math-answer/#findComment-1436993 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.