TIL NaNs and infinities slow down programs

Правка en1, от johnchen902, 2016-07-19 21:06:10

Today I learned that NaNs and infinites may slow down programs significantly. So instead of

// some computation that produce NaN when arg == 0
if(arg == 0) // special case
    result = 0;

one should write

if(arg == 0)
    result = 0; // special case
else
    // some computation that produce NaN when arg == 0

Compare submission 19257027 and 19257693 and you'll see.

Теги floating-point

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский johnchen902 2016-07-19 21:06:10 483 Initial revision (published)