It seems like some functions that have outputs in cases might use an if statement as the underlying implementation, thus causing branching. I don't think it does, but I wonder.
For sign(x), if the number is positive, negative, or zero, it reruns 1, -1 and 0 respectively.
So how does this function work?
Implementation details are always implementation-specific. So how this construct is implemented depends entirely on the vendor (and ultimatively, the abilities of the underlying hardware).
However, it is extremely unlikely that any real-world implementation would use a branch for the sign()
opertation. The sign can be easily determined by looking at the sign bit which is present in most real-world floating-point formats, especially IEE 754. This can be easily implemented with logic - much easier as your typical floating point arithmetic function.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With