#46564 [Com]: bcmod( '1071', '357.5' ) returns '0'

From: Date: Thu, 13 Nov 2008 13:20:44 +0000
Subject: #46564 [Com]: bcmod( '1071', '357.5' ) returns '0'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-130940@lists.php.net to get a copy of this message
ID: 46564 Comment by: shelby at coolpage dot com Reported By: shelby at coolpage dot com Status: Open Bug Type: BC math related Operating System: BSD PHP Version: 5.2.6 New Comment: Correction, need ">= 0": function bcmod( $op, $mod, $scale ) { while( ($t = bcsub( $op, $mod, $scale )) >= 0 ) $op = $t; return $op; } Previous Comments: ------------------------------------------------------------------------ [2008-11-13 13:03:27] support at coolpage dot com Here is function that works correctly: function bcmod( $op, $mod, $scale ) { while( ($t = bcsub( $op, $mod, $scale )) > 0 ) $op = $t; return $op; } ------------------------------------------------------------------------ [2008-11-13 12:46:51] shelby at coolpage dot com Description: ------------ bcmod( '1071', '357.5' ) returns '0' Reproduce code: --------------- echo bcmod( '1071', '357.5' ); Expected result: ---------------- bcmod( '1071', '357.5' ) should return '356' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=46564&edit=1

« previous php.bugs (#130940) next »