N
ng_mr
No, not a question about "banker's rounding" or whatever it's called.
I want to round a double to the nearest 100th, so I perform the
following:
// original is a double
double result = Math.Round( original, 2 );
But I'm not happy with the results. E.g. if original is
-2533.85009765625 the result is -2533.85009765625 (as viewed in the
debugger and as output via displayed in the UI when converted to a
string.)
Also, if original is already a simple rounded value such as 10.23, the
resulting value is 10.229999542236328!!
Am I right to expect better results from Math.Round? Is this a bug in
the CLR? Is there a compiler switch or something that might affect
this?
Thanks,
Mel.
I want to round a double to the nearest 100th, so I perform the
following:
// original is a double
double result = Math.Round( original, 2 );
But I'm not happy with the results. E.g. if original is
-2533.85009765625 the result is -2533.85009765625 (as viewed in the
debugger and as output via displayed in the UI when converted to a
string.)
Also, if original is already a simple rounded value such as 10.23, the
resulting value is 10.229999542236328!!
Am I right to expect better results from Math.Round? Is this a bug in
the CLR? Is there a compiler switch or something that might affect
this?
Thanks,
Mel.