You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Eduardo Ponce / @edponce:
IEEE 754 defines rules for +0.0 and -0.0, thus sign(+0.0) = 1 and sign(-0.0) = -1. On the other hand, integral zero results in sign(0) = 0. Is this behavior reasonable?
This approach will result in different behavior for floating-point and integral operands.
Floating-point sign(X) = -1 if X <= -0.0 1 if X >= 0.0
Integral sign(X) = -1 if X < 0 0 if X = 0 1 if X > 0
Ian Cook / @ianmcook: @edponce I think sign(0.0) should return 0 regardless of the sign of the floating point zero, for two reasons: (a) This is what Python, R, all SQL engines, etc. do and therefore it is what users will expect. (b) There is little practical use in knowing the sign of a floating point zero value; this sign kernel will be more consistent and more useful in more ways if it always returns sign zero for value zero.
Neal Richardson / @nealrichardson:
I definitely have seen applications that rely on the sign of 0. We may want a FunctionOption for that--but we can also defer that until someone reports it, which as Ian suggests, may never happen.
Activity
asfimport commentedon May 24, 2021
Eduardo Ponce / @edponce:
IEEE 754 defines rules for +0.0 and -0.0, thus sign(+0.0) = 1 and sign(-0.0) = -1. On the other hand, integral zero results in sign(0) = 0. Is this behavior reasonable?
This approach will result in different behavior for floating-point and integral operands.
-1 if X <= -0.0
1 if X >= 0.0
-1 if X < 0
0 if X = 0
1 if X > 0
asfimport commentedon May 25, 2021
Ian Cook / @ianmcook:
@edponce I think sign(0.0) should return 0 regardless of the sign of the floating point zero, for two reasons: (a) This is what Python, R, all SQL engines, etc. do and therefore it is what users will expect. (b) There is little practical use in knowing the sign of a floating point zero value; this sign kernel will be more consistent and more useful in more ways if it always returns sign zero for value zero.
asfimport commentedon May 25, 2021
Eduardo Ponce / @edponce:
Thanks for the feedback @ianmcook, I agree and will make this change.
asfimport commentedon May 25, 2021
Neal Richardson / @nealrichardson:
I definitely have seen applications that rely on the sign of 0. We may want a FunctionOption for that--but we can also defer that until someone reports it, which as Ian suggests, may never happen.
asfimport commentedon Jul 15, 2021
Ben Kietzman / @bkietz:
Issue resolved by pull request 10395
#10395