I have some (legacy embedded c) code which produces a .csv file by means of some sprintf
calls. Occasionally I see values of 1.#QO
. I've tried reproducing those values with conditions which should give negative infinity, positive infinity and NaN but none of them appear to give me the magical 1.#QO
result. So what is it that produces that value?
...and yes, I know there's obviously something going wrong in the maths which produce that value, but understanding what it means would assist in the debugging effort.
[Edit 1] The actual line which does the conversion is:
sprintf_s(txt, CSV_HEADER_SIZE, "%.3f", value);
where:
#define CSV_HEADER_SIZE (100)
char txt[CSV_HEADER_SIZE];
I'm compiling with MS Visual Studio 2008.
[Edit 2] A bit more digging shows 0xFFFFFFFF
gives -1.#QO
:
unsigned int i = 0xFFFFFFFF;
float* f = (float*)&i;
printf("%.3f", *f); // gives -1.#QO
..and looking at that in the Visual Studio debugger expands it to -1.#QNAN00
so it looks like this is probably a Microsoft-specific representation of NaN
?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…