Fragen im Vorstellungsgespräch bei Naughty Dog: What's the fastest way to tel... |

Frage im Vorstellungsgespräch

Software Engineer-Vorstellungsgespräch

What's the fastest way to tell if 2 signed floats are the

  same polarity?

Antwort im Vorstellungsgespräch

3 Antworten


Perform a XOR comparison of the most significant bit of both numbers. If the result is 1, the resulting float will be negative. Otherwise, it is positive.

John Georgantas am 19.05.2016

Although simpler, the multiplication answer is incorrect: the multiplication can overflow, and the comparison with zero will then be incorrect. The XOR answer is the superior one.

Anonymous am 07.08.2016

Multiply them together and compare greater than zero.

Anonym am 04.11.2014

Antwort oder Kommentar posten

Um dies zu kommentieren, bitte anmelden oder Konto anlegen.