# New Ticket Created by  "Carl Mäsak" 
# Please include the string:  [perl #60674]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=60674 >


<masak> what should the behaviour of sign($x) be when $x is complex?
<masak> rakudo: say sign($_) for 42, -42, 0+42i
<p6eval> rakudo 32877: OUTPUT[1␤-1␤1␤]
<masak> somehow, that last one doesn't feel right to me.
<masak> I vote for either an error or $x/abs($x)
<PerlJam> why would it be an error?
<masak> because 'sign' could be argued to only be applicable to real numbers.
<masak> i.e. positive numbers, negative numbers, and zero.
<PerlJam> but what is it specced to do?  :-)
<masak> ah.
<masak> it's supposed to return the 'sign' of a number.
<masak> i.e. +1, -1 or 0 for the above three groups.
<masak> in that way, it's a bit like <=>, except it always compares to 0
<PerlJam> oh, it's wrong anyway I think.
<PerlJam> rakudo: say sign(-5+3i);
<p6eval> rakudo 32877: OUTPUT[1␤]
<PerlJam> that can't be right.
<masak> it always returns 1 on complex numbers.
* masak reports a bug

Reply via email to