DWORDs and doing the division that way, then convert them back. For
exmaple.
I'd tried to use already Tom's link, I found it in some previous
posts. It doesn't work.
I'm calling RoundDouble( 0.80000000000000004, 4 )
At the end this function divides 80 by 100 and return of course
0.80000000000000004
So I think the problem is that "double" is also "float" in C++
It may sound stupid, but I'm going to use SQL Server to get the proper
result, it has type "numeric", if in SQL Server I divide numeric =
80.00, by numeric = 100.00 it returns correct result
0.80000000000000000
but if in SQL Server I divide float = 80.00, by float = 100.00 it
returns again result
0.80000000000000004
So SQL Server has numeric type and C++ doesn't. So I'll write some
SQL Server stored procedure, which will be using numeric data types.
Thanks,
Alex
On May 31, 11:36 am, MrAsm <m...@usa.com> wrote:
On 31 May 2007 08:10:16 -0700, Alex <alsim...@hotmail.com> wrote:
Everybody,
I'm lost
I have double d1 = 80.00
double d2 = 100.00
double result = d1/d2;
result = 0.80000000000000004 !!??
Why appears this "4" at the end!!??
It really makes difference for me.
Hi,
Floating point math is not an "exact" math (like e.g. integer math) in
computers.
When you do operations on floats (or doubles), you cannot expect an
"exact" result; there could be cancellation, rounding errors, etc.
In addition to Tom's link, you might consider also this:
http://cch.loria.fr/documentation/IEEE754/ACM/goldberg.pdf
MrAsm