Is there anyway to get a double type variable to print in scientific notation? My problem is to print some values to a file, but I end up with BIG values that would make MUCH more sense if I printed them in scientific notation.

Printable View

- 02-18-2002UnregisteredScientific Notation
Is there anyway to get a double type variable to print in scientific notation? My problem is to print some values to a file, but I end up with BIG values that would make MUCH more sense if I printed them in scientific notation.

- 02-18-2002Unregistered
I think I solved the scientific notation problem, (the values were printed to a file, so I looked up fprintf) but one of my values is

-1.#QNAN

any idea why? - 02-18-2002Salem
NAN is Not A Number

Undefined floating point results (eg. divide by 0) result in either a quiet NAN (QNAN) or a signalling NAN. A signalling NAN would have halted your program.

Any operation on a NAN results in a NAN, so it doesn't go away just like that.

Basically, you've got a math problem - either in the calculation, or because you're providing an uninitialised float as input.