From: George on
Hello everyone,


If a and b are both float (or double, I think it does not matter?), and I
want to calculate a/b. I am wondering whether there will be any issues which
make the calculation result in-accurate compared with the calculation result
by-hand (on a paper). :-)

For example, if a is too big, or if b is too small? If such issue exists,
what is the best practices to calculate a/b?


thanks in advance,
George
From: Carl Daniel [VC++ MVP] on
George wrote:
> Hello everyone,
>
>
> If a and b are both float (or double, I think it does not matter?),
> and I want to calculate a/b. I am wondering whether there will be any
> issues which make the calculation result in-accurate compared with
> the calculation result by-hand (on a paper). :-)
>
> For example, if a is too big, or if b is too small? If such issue
> exists, what is the best practices to calculate a/b?

http://www.physics.ohio-state.edu/~dws/grouplinks/floating_point_math.pdf
http://docs.sun.com/source/806-3568/ncg_goldberg.html

Both of these links are to different versions of the same document. Read
it. Understand it.

-cd


From: George on
Good reference, thanks cd!


regards,
George

"Carl Daniel [VC++ MVP]" wrote:

> George wrote:
> > Hello everyone,
> >
> >
> > If a and b are both float (or double, I think it does not matter?),
> > and I want to calculate a/b. I am wondering whether there will be any
> > issues which make the calculation result in-accurate compared with
> > the calculation result by-hand (on a paper). :-)
> >
> > For example, if a is too big, or if b is too small? If such issue
> > exists, what is the best practices to calculate a/b?
>
> http://www.physics.ohio-state.edu/~dws/grouplinks/floating_point_math.pdf
> http://docs.sun.com/source/806-3568/ncg_goldberg.html
>
> Both of these links are to different versions of the same document. Read
> it. Understand it.
>
> -cd
>
>
>