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

%% with zero denominator

Thread Next
From:
Sean McAfee
Date:
December 11, 2017 03:42
Subject:
%% with zero denominator
Message ID:
CANan03aLX0DX_t09-wgiei=G0M1ieZascUmqhES7jm5OG8C0JA@mail.gmail.com
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About