Audrey Tang wrote: > Assuming "num" uses the underlying floating point semantic (which may > turn 0/0 into NaN without raising exception), what should the default > "Num" do on these forms? > > 0/0 > 0*Inf > Inf/Inf > Inf-Inf > 0**0 > Inf**0 > 1**Inf > > Several options: > - - Use whatever the underlying "num" semantics available > - - Always "fail" > - - Always "die"
Given a choice between the latter two, I'd rather go with Always "fail" (i.e., return "undefined"). This lets people handle matters with error-trapping if they like, without removing the possibility of handling it by testing the result for "definedness". > - - Specify them to return some definite value. > > At this moment, Pugs defines them ad-hocly to: > > 0/0 == die "Illegal division by zero" See above; besides, math classes generally teach that 0/0 is undefined. > 0*Inf == NaN > Inf/Inf == NaN > Inf-Inf == NaN These expressions are no more NaN than Inf is. I'd handle them as: 0*Inf == undef Inf/Inf == Inf Inf-Inf == Inf > 0**0 == 1 > Inf**0 == 1 I know that x**0 == 1 if x is anything other than 0 or Inf; meanwhile, 0**y == 0 if y is anything other than 0, and Inf**y == Inf if y is anything other than 0. I'd say that these two should normally be undef. > 1**Inf == 1 1**y == 1 when y is anything but Inf; x**Inf == Inf if |x| is greater than 1; and x**Inf == 0 if |x| is less than 1. Again, 1**Inf == undef. > But I'd like to seek a more definite ruling. Ditto. -- Jonathan "Dataweaver" Lang