signbit question
Adam D. Ruppe
destructionator at gmail.com
Thu Mar 15 16:29:55 UTC 2018
On Thursday, 15 March 2018 at 15:28:16 UTC, Miguel L wrote:
> Why does std.math.signbit only work for floating point types?
Integers are stored in an entirely different way, twos-complement
instead of having a sign bit.
You probably shouldn't be using the sign bit function at all, it
is for digging deeper into the float binary format. Instead, I'd
just say
if(f > 0 && i > 0)
if(f < 0 && i < 0)
if(f == 0 && i == 0)
etc. in math stuff to see if they have the same sign. floats have
weird things like +0 and -0 which doesn't exist at all in ints...
More information about the Digitalmars-d-learn
mailing list