Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Lets say you have a high scoring game like geometry wars, why type would you use for the score and how should you handle overflow?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

Depending on the scoring system in your game and the type you use you may never need to wrap. For example, an unsigned 64-bit integer can hold a maximum value of 9,223,372,036,854,775,807. Long before games get close to that most would start displaying problems rendering a number that long in the UI. It would also take an awfully long time to rack up a score that big so it's not really worth worrying about.

Depending on how you implement a leaderboard (i.e. use a third-party system for online scoreboards) then the format of the score may already be decided for you on their servers.

share|improve this answer
    
I agree. int should be sufficient, and UInt64 should almost never need to be exceeded. –  Nate May 17 '11 at 21:56
1  
9,223,372,036,854,775,807 is the maximum value for a signed 64-bit integer. For an unsigned 64-bit integer, the maximum value is 18,446,744,073,709,551,615. –  Michael Madsen May 17 '11 at 22:37
1  
You could use the System.Numerics.BigInteger type. It supposedly doesn't have an upper limit (performance will probably degrade if it gets too large). –  Michael Coleman May 17 '11 at 23:15
    
@Michael Madsen Doh! Twice as long then before it wraps! ;) Ta –  Roger Perkins May 18 '11 at 0:07
    
18 billion billion is one hell of a score. –  Nick Bedford May 18 '11 at 4:34

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.