Reputation: 59
I am creating 1D and 2D array from a file that contains lines that look like this:
42857000 -923070 0 0 -7887 428570 -546190 -4285700 546190 0 -6.5 -0.15384 6.5 0.15384 0.007 0 0 42857000 360570 0
When I populate the arrays from the file, they get converted to scientific notation:
42857000 >>>>> 4.2857000e+007 etc!!!
Is there anyway to stop this?
My arrays are defined as follows:
float aMatrix[DEFROWS][DEFCOLS] = {0.0};
float bMatrix[DEFCOLS] = {0.0};
This issue is causing my app to crash.
Thanks.
Upvotes: 0
Views: 599
Reputation: 8232
Is it crashing on reading it in or sending it out? Are you using cout or printf? One extremely common way to crash it to use printf with a %d and send it a floating point value.
Upvotes: 0
Reputation: 61900
I assume this is just from printing with cout
. If that's the case, use std::fixed
:
std::cout << std::fixed << whateverNumberCurrentlyInScientific;
Upvotes: 3