Answer the question
In order to leave comments, you need to log in
Why is there a signum function in the Num class?
Can you give examples of using this function?
Answer the question
In order to leave comments, you need to log in
mlyamasov , is a relative of abs from the world of complex numbers:
That is,abs z
is a number with the magnitude ofz
, but oriented in the positive real direction, whereassignum z
has the phase ofz
, but unit magnitude.
And what about Haskell? This is a general mathematical function.
https://ru.m.wikipedia.org/wiki/Sgn
The signum function determines the sign of the number passed to it as an argument.
Prelude> signum 4
1
Prelude> signum (-4)
-1
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question