Sign, Sign, Everywhere a Sign

New blog post: Degenerate Conic | Sign, Sign, Everywhere a Sign

I think there was a comment here in this forum somewhere (which i can no longer find) about how the sign() function arguments are confusing. So, don’t feel bad, even the giants of the 1980s apparently were also confused. :grimacing:

Also curious if anyone here ever actually used ALGOL. I’ve only seen it in old books and papers. I didn’t realize that Backus was also one of its creators.

1 Like

The Fortran definition of SIGN pre-dates the ALGOL-60 definition, though it was called SIGNF in early Fortrans. ALGOL probably should have called theirs “signum”.

1 Like

C has a similar function, but with a better name:

#include <math.h>
double copysign(double x, double y);

The copysign functions produce a value with the magnitude of x and the sign of y. If x or y is an unsigned value, the sign (if any) of the result is implementation-defined. On implementations that represent a signed zero but do not treat negative zero consistently in arithmetic operations, the copysign functions should regard the sign of zero as positive.

(C2023 standard)