develooper Front page | perl.perl6.users | Postings from December 2017

%% with zero denominator

Thread Next
Sean McAfee
December 11, 2017 03:42
%% with zero denominator
Message ID:
I think of %% as being Perl 6's is-divisible-by operator, so I was a little
surprised to discover this behavior:

> 1 %% 0
Attempt to divide 1 by zero using infix:<%%>
  in block <unit> at <unknown file> line 1

The docs say a %% b is True if a % b is 0, so the error is as-designed, at
least.  But mightn't it make more sense for %% to just return False when
given a second zero operand?  After all, the answer to "is n divisible by
zero" is false for any n--there's no need to try to go through with the
division to ascertain this.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About