On Tue, Apr 11, 2006 at 11:44:43PM +0800, Dan Jacobson wrote:
> Package: perl
> Version: 5.8.7-10
> Severity: normal
> File: /usr/bin/a2p
> 
> Big fat a2p bug, not mentioned on man page even:
> $ awk 'BEGIN{print 0.6 % 11}'
> 0.6
> $ echo 'BEGIN{print 0.6 % 11}'|a2p|perl
> 0
> $ echo 'BEGIN{print 0.6 % 11}'|a2p|tail -1
> print 0.6 % 11;
> If it is OK that 0.6=0 sometimes then the a2p man page should say why.
> 
> And perlop is wrong:

Not wrong.  Incomplete maybe...

>        Binary "%" computes the modulus of two numbers.  Given integer
>        operands $a and $b: If $b is positive, then "$a % $b" is $a
>        minus the largest multiple of $b that is not greater than $a.
> As it doesn't mention what happens to non integers!! OK, what about
> non-integers?! Say something!

That would be because, mathematically, modulus is typically an integer 
operation.  It appears from your experimentation that you have a good 
idea of what actually happens.  My guess is that you could have actually 
submitted the following patch.

==== //depot/perl/pod/perlop.pod#145 (text) ====

@@ -260,7 +260,9 @@
 C<$a> minus the largest multiple of C<$b> that is not greater than
 C<$a>.  If C<$b> is negative, then C<$a % $b> is C<$a> minus the
 smallest multiple of C<$b> that is not less than C<$a> (i.e. the
-result will be less than or equal to zero). 
+result will be less than or equal to zero).  If the operands
+C<$a> and C<$b> are floting point values, only the integer portion 
+of C<$a> and C<$b> will be used in the operation.
 Note that when C<use integer> is in scope, "%" gives you direct access
 to the modulus operator as implemented by your C compiler.  This
 operator is not as well defined for negative operands, but it will

Attachment: signature.asc
Description: Digital signature

Reply via email to