Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Defining gold.

Defining gold.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by USER007   (124 posts)  Bio
Date Fri 17 Jun 2005 12:02 AM (UTC)

Amended on Fri 17 Jun 2005 12:04 AM (UTC) by USER007

Message
I've managed to upgrade the gold system to use long double instead of int everything compiles cleanly/works fine. I then decided to add:

#define MAX_GOLD 50000000000

and replace all the hard coded values, but when I compile I get this warning on several files:

warning: integer constant is too large for "long" type

And the lines that are giving me the warning are:

if ( newbet > MAX_GOLD )
{

Where exactly would I need to change this to allow me to go past int, if its too much of a hassle then I think I'll just leave the numbers hard coded.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Fri 17 Jun 2005 12:39 AM (UTC)
Message
Why are you using a long double for your gold? Why is not a long or a long-long (64-bit) enough? An unsigned long-long gives you 18,446,744,073,709,551,616 possible values and even a normal unsigned, 32-bit long (usually, long = int, by the way) gives you 4,294,967,296 possible values. I note that your max is more than that (which is an 'interesting' game design) but still, you really don't need to use a long double. That's just silly. 128 bits is monstrous overkill.

Anyhow, you're getting an error because your constant is too large for type long. (46 billion too large.) Either change the type of 'newbet' or make your maximum within the bounds of the long type.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


11,252 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.