On 16 November 2011 04:35, Ali Çehreli <[email protected]> wrote: > Some floating point operations produce .nan: > > import std.stdio; > > void main() > { > double zero = 0; > double infinity = double.infinity; > > writeln("any expression with nan: ", double.nan + 1); > writeln(" zero / zero : ", zero / zero); > writeln(" zero x infinity : ", zero * infinity); > writeln("infinity / infinity : ", infinity / infinity); > writeln("infinity - infinity : ", infinity - infinity); > } > > Last time I checked, I think the program above would produce nan for all of > those operations. Now some are -nan when compiled with 64-bit dmd 2.056 on > Linux: > > any expression with nan: nan > zero / zero : -nan > zero x infinity : -nan > infinity / infinity : -nan > infinity - infinity : -nan > > Is that expected? Does it matter? > > Ali >
This behaviour may be due to the libraries rather than the compiler. But whether the bit that controls signed-ness is on or off, doesn't stop the value being NaN. So I would not give much concern to the result. -- Iain Buclaw *(p < e ? p++ : p) = (c & 0x0f) + '0';
