Re: [PHP] Modulus and floating point...

2002-01-04 Thread Bogdan Stancescu
You can consider doing this: $number=102.52; $fraction=$number-floor($number); $number=($number % 50)+$fraction; Basically it's the exact solution you're suggesting, just that you don't have to do any string stuff. PHP's behaviour is normal - modulus is generally intended for integers... Bogdan

[PHP] Modulus and floating point...

2002-01-04 Thread Boget, Chris
Consider the following: $number = 102.52; echo $number % 50; echo bcmod( $number, 50 ); in both cases, it's spitting out "2". Why is it not spitting out "2.52"? Is there a way I can get that information? w/o having to parse the string, breaking it up, getting the modulus and then adding it ba