943,910 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1405
  • C++ RSS
You are currently viewing page 2 of this multi-page discussion thread; Jump to the first page
Jan 12th, 2009
0

Re: (very) simple math not working perhaps due to to large numbers?

can i just change those values? either just by editing limits.h or by changing the value for a specific program? or can i make a variable of unlimmited size?
Generally, you cannot. The contents of limits.h generally reflects technical limits on capability of your compiler on your target operating system. Most compilers will need to be rewritten/extended/modified to support a change of those values.
Reputation Points: 193
Solved Threads: 32
Posting Whiz in Training
grumpier is offline Offline
206 posts
since Aug 2008
Jan 13th, 2009
0

Re: (very) simple math not working perhaps due to to large numbers?

okay, is there anything i can do?
Reputation Points: 18
Solved Threads: 4
Junior Poster
Bladtman242 is offline Offline
163 posts
since Dec 2008
Jan 13th, 2009
0

Re: (very) simple math not working perhaps due to to large numbers?

You can implement a class type that has the attributes you want (or find such a class type that someone else has implemented). Internally, that type might use an array of integers or (as Freaky_Chris suggested) a string to represent larger values. You would need to define mathematical operations and also things like streaming (so you can read or write the data to a file stream).
Reputation Points: 193
Solved Threads: 32
Posting Whiz in Training
grumpier is offline Offline
206 posts
since Aug 2008
Jan 13th, 2009
0

Re: (very) simple math not working perhaps due to to large numbers?

well file i/o sounds fine, but about defining mathematical operations and.. still the string and class thing? i dont get it :-( i havent worked with structures and classes for a looong while, so i will re-read some documentation on the subject:-) what do you mean with defining mathematical operations?

would splitting up the large numbers and assigning them to an array of ints help anything??
Reputation Points: 18
Solved Threads: 4
Junior Poster
Bladtman242 is offline Offline
163 posts
since Dec 2008
Jan 13th, 2009
0

Re: (very) simple math not working perhaps due to to large numbers?

Mathematical operations: operators like * (multiplication), + (addition), - (subtraction or negation), / (division), etc.

Splitting up large number and assigning them to an array of ints is one way: such things can be implemented using a class.
Reputation Points: 193
Solved Threads: 32
Posting Whiz in Training
grumpier is offline Offline
206 posts
since Aug 2008
Jan 13th, 2009
0

Re: (very) simple math not working perhaps due to to large numbers?

By defining mathematical operations he means you need to deal with things such as addition, multiplication etc.
You would do this by overloading the different operators such as operator+().
Also the you will want to overload the stream operators as grumpier suggested that would be the << and >> so that the data can be outputted into files and the standard output. Aswell as read into your data type.

Chris
Reputation Points: 325
Solved Threads: 118
Master Poster
Freaky_Chris is offline Offline
702 posts
since Apr 2008
Jan 14th, 2009
0

Re: (very) simple math not working perhaps due to to large numbers?

I really dont mean to waste anyone's time, so i hope you will bare with me once again.

@Chris, you want me to save the data in files instead of in variables? and then make the calculation by changing the file instead of a variable?

@grumpier, thanks, at least that makes sence to me now ;-)

EDIT: If i use a file instead of a variable i would still have to asign the value to variable when i want to use it, right?
Last edited by Bladtman242; Jan 14th, 2009 at 12:27 pm.
Reputation Points: 18
Solved Threads: 4
Junior Poster
Bladtman242 is offline Offline
163 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: comments please
Next Thread in C++ Forum Timeline: need some guidance





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC