Thread Illegal modulus zero: auch bei 0 vor dem komma (7 answers)
Opened by MatthiasW at 2008-10-21 17:33

Gast Gast
 2008-10-21 17:44
#115676 #115676
% funktioniert nur mit Ganzzahlen (Integers).
Die 0.3 wird in dem Zusammehang automatisch zu einem Integer konvertiert .


~ perl -e"print int 0.3"
0
~

Und 0.3 ist eben dann 0 wie du siehst.

//EDIT:
Ansonsten steht zu %:
Quote
If the operands $a and $b are floating point values and the absolute value of $b (that is abs($b)) is less than (UV_MAX + 1) , only the integer portion of $a and $b will be used in the operation (Note: here UV_MAX means the maximum of the unsigned integer type). If the absolute value of the right operand (abs($b)) is greater than or equal to (UV_MAX + 1) , "%" computes the floating-point remainder $r in the equation ($r = $a - $i*$b) where $i is a certain integer that makes $r should have the same sign as the right operand $b (not as the left operand $a like C function fmod() ) and the absolute value less than that of $b .

View full thread Illegal modulus zero: auch bei 0 vor dem komma