[ back to toc ]

add 2 floating point numbers

Date: 2002/04/03 13:18

Q:
hi,
i need to add two floating point numbers with the maximum possible range.
i wanted to know how do i store them or what should i use to store such
values as there would definitely be an overflow ?

thanks.
A:
I do not really understand what you want to achieve. Do you want to create
an overflow error?

regards,
Peter
Q:
hi peter,

thanks for your time. to be very frank you are the first person to have
got what i'm trying to point to. sorry if i was very vague about my
question. yes, in general such an operation would result in an overflow
which i do not want. i want to do the following without an error
lets suppose, i declare variables
long double a,b,c;

a=1.1 E 4932; // this is the max possible range for long double
b=1.1 E 4932; // this is the max possible range for long double

c=a+b; // here there would be an overflow

now how do i add a and b is my question and display their result. hope i
could make myself clear this time. thanks.

A:
What you need is the GNU APM package. APM stands for arbitrary precision
mathematics. That limits the size or magnitude of the numbers only by the
available memory.

Regards,
Peter

[ back to toc ]