Pregunta de entrevista de Naughty Dog: What's the fastest way to tel... | Glassdoor.es

Pregunta de entrevista

Entrevista para Software Engineer

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

  same polarity?
Respuesta

Respuesta de la entrevista

3 respuestas

3

Multiply them together and compare greater than zero.

Candidato a entrevista el 4 nov. 2014
3

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 el 19 may. 2016
2

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 el 7 ago. 2016

Añadir respuestas o comentarios

Para comentar esto, inicia sesión o regístrate.