adding huge doubles

D

dave

I'm trying to learn this. My problem, I have 2 strings that represent
floats.
I want to add them together.
Should I look at using Cint to convert each character in the string and add
individually?
or would grouping the "digits" in the string by say 10 or 20 and working the
smaller parts?
Would i loose something by grouping in that way?
Or is there a faster/better way?
I have been thinking about this for a while and I don't want to start the
design off wrong.


I can't convert them to floats because I need to keep the precision.
I need to keep it c++ cause I don't remember assembler.

thanks
dave
 
V

Victor Bazarov

dave said:
I'm trying to learn this. My problem, I have 2 strings that represent
floats.
I want to add them together.
Should I look at using Cint to convert each character in the string
and add individually?
or would grouping the "digits" in the string by say 10 or 20 and
working the smaller parts?
Would i loose something by grouping in that way?
Or is there a faster/better way?
I have been thinking about this for a while and I don't want to start
the design off wrong.


I can't convert them to floats because I need to keep the precision.
I need to keep it c++ cause I don't remember assembler.

Just look for "arbitrary precision floating point" or "bigint" or
something like that, on the Web.

V
 
D

Dave Rahardja

I'm trying to learn this. My problem, I have 2 strings that represent
floats.
I want to add them together.
Should I look at using Cint to convert each character in the string and add
individually?
or would grouping the "digits" in the string by say 10 or 20 and working the
smaller parts?
Would i loose something by grouping in that way?
Or is there a faster/better way?
I have been thinking about this for a while and I don't want to start the
design off wrong.


I can't convert them to floats because I need to keep the precision.
I need to keep it c++ cause I don't remember assembler.


What's Cint?

Will a double have enough precision?

You can search for an arbitrary precision floating-point library to use, or
use a vector to hold the digits, and iterate through them, adding digits a
pair at a time.
 
G

Greg

dave said:
I'm trying to learn this. My problem, I have 2 strings that represent
floats.
I want to add them together.
Should I look at using Cint to convert each character in the string and add
individually?
or would grouping the "digits" in the string by say 10 or 20 and working the
smaller parts?
Would i loose something by grouping in that way?
Or is there a faster/better way?
I have been thinking about this for a while and I don't want to start the
design off wrong.


I can't convert them to floats because I need to keep the precision.
I need to keep it c++ cause I don't remember assembler.

thanks
dave

How many digits of precision are needed for the floating point values?
Simply adding the numbers will not require any additional precision.

Assuming that the C/C++ compiler supports long doubles, it may be
possible to represent as many as 18 digits of precision in a floating
point variable.

Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top