in reply to Re^2: Test modulus zero in bigint
in thread Test modulus zero in bigint
Makes sense to me :) kinda
perl -Mbignum -E " for $x( -1,0,1){ $y = 0; sub F{say $x % $y} F; $x +->bdiv; F;} " -1 -inf 0 NaN 1 inf
The bdiv seems to force/convert the numeric representation to stringy value via binf/bnan
Its a bit odd but details of division by zero are in comments https://metacpan.org/source/PJACKLAM/Math-BigInt-1.999726/lib/Math/BigInt.pm
# Divide by zero and modulo zero. # # Division: Use the common convention that x / 0 is inf with the s +ame sign # as x, except when x = 0, where we return NaN. This is also what +earlier # versions did. # # Modulo: In modular arithmetic, the congruence relation z = x (mo +d y) # means that there is some integer k such that z - x = k y. If y = + 0, we # get z - x = 0 or z = x. This is also what earlier versions did, +except # that 0 % 0 returned NaN. # # inf / 0 = inf inf % 0 = inf # 5 / 0 = inf 5 % 0 = 5 # 0 / 0 = NaN 0 % 0 = 0 # -5 / 0 = -inf -5 % 0 = -5 # -inf / 0 = -inf -inf % 0 = -inf
|
|---|