Re: A few more jobs/qustions

From: Jaco van Iterson (J.C.vanIterson@ET.TUDelft.NL)
Date: 11/20/95


On Mon, 20 Nov 1995 BryanRoach@aol.com wrote:

> Actually.... You really wouldn't need 3 variables, just some fancy math...
> If you have 3 currency denominators, the easy way is to just declare the
> variable as floating point instead of integer, then base your money system
> off decimal places to determine what coins the charater has. For example...
> 
> 150.23  
> a good system here would be:
> 1 silver = 100 copper
> 1 gold = 100 silver 
> 
> In the case above,  by grabbing the decimal place value of the floating point
> variable, the character would have 23 copper, 50 silver, and 1 gold piece. 
> 
> - Brian
> 

This would limit your copper and silver to 99 pieces.
If you're going to use a real variable for the coins you better make
100500023.0
1 gold, 50 silver and 23 copper
then you can have 9999 copper and silver pieces which should be more
then you can carry.

Ofcourse if you get an overflow now, you would only get 1 silver coin back
for every 10000 copper coins :(

Maybe using 3 variables isn't such a bad idea.
(Whose idea was it? Yours i guess)

You will also need to make functions to enable you to chance coppers for
silver and gold at a bank or in a shop.

And there will be a problem when you have only gold and the small-town
shopkeeper hasn't got chance for you.

Anyway, implementing this would be fun but no thing a newbie wants to start
with. Unless ofcourse when you do a half-harted job like:
/* int gold, silver, copper and coins; */
gold = coins/10000;
silver = (coins%10000)/100;
copper = (coins%10000)%100;


Which gives you the value of your coppers calculated into
gold, silver and coppers (but you still have only coppers).



Jaco



This archive was generated by hypermail 2b30 : 12/07/00 PST