944,135 Members | Top Members by Rank

Ad:
Jan 3rd, 2007
0

software design problem

Expand Post »
Hi,

I'm working on a small software project and there is one tricky problem to solve.

Here is overview of the program:
It is a business software that has to keep track of expenses and earnings and to show the current balance (negative or possitive). Whenever there is someone that has to pay something to the given business the operator creates a receipt in the system and the money is added to the ballance. On the other hand whenever there is an expense the operator creates an expense receipt and the money is subtracted from the balance. The program should store all receipts.

The tricky part is how to compute the balance. The easiest way is to sum the expenses, sum the earnings and subtract the expenses from the earnings but there is a problem with this approach - if the firm is generatin alot of expenses or/and earnings at some point the sum of either the earnings or the expenses would go out of range of the data type that I might me using. So the question is how to solve this problem without the possibility of overflow?

One approach might be to group the receipt into periods - for example all receipts that were created on the same day would be in one period and every period would have its own balance - earnings minus expenses for that period. This way whenever we want to get the current balance the program will just add the balances of the all periods and now overflow is very unlike to occur. Is this a reasonable solution?

I would appreciate any comment, suggestion, ideas on this problem.
Thanks in advance and I wish a happy New Year to all of you!
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
va-yik-ra is offline Offline
1 posts
since Jan 2007
Jan 3rd, 2007
0

Re: software design problem

Quote ...
So the question is how to solve this problem without the possibility of overflow?
Use a library like GMP for arbitrary precision math. That's really the only way to do it without heaping annoying restrictions on the end user.
Reputation Points: 84
Solved Threads: 15
Posting Whiz in Training
Ravalon is offline Offline
209 posts
since Dec 2006

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 IT Professionals' Lounge Forum Timeline: Degree help
Next Thread in IT Professionals' Lounge Forum Timeline: Dell Latitude - Multiple Monitors not working





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


Follow us on Twitter


© 2011 DaniWeb® LLC