Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Can't write integer to file correctly (DBP)

Author
Message
jaden decar
17
Years of Service
User Offline
Joined: 26th Jan 2007
Location:
Posted: 11th Mar 2007 03:02
Well, it seems that ever time I write an integer to a file, it stores it fine, until the value goes above 220, in which case it resets to a random number under 100. I would really like some help on this, as it is incredibly important to my game.

P.S. here's the code:

Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Mar 2007 03:43
The maximum value of a byte is 255, so if you go any higher it will wrap around.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
jaden decar
17
Years of Service
User Offline
Joined: 26th Jan 2007
Location:
Posted: 11th Mar 2007 03:49 Edited at: 11th Mar 2007 03:52
oh, would there be a way to get around that then?

EDIT: Nevermind, I just thought of a way around this using a long and a second variable.
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Mar 2007 04:31
Quote: "oh, would there be a way to get around that then?"

Yes, use a bigger data type.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)
Inverted
17
Years of Service
User Offline
Joined: 19th Nov 2006
Location: Oregon
Posted: 14th Mar 2007 16:52
What data type would you suggest


Come take a look!
Benjamin
21
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 14th Mar 2007 18:24
A bigger one. A word can store a value from 0 to 65536.

Tempest (DBP/DBCe)
Multisync V1 (DBP/DBCe)

Login to post a reply

Server time is: 2024-09-25 19:12:57
Your offset time is: 2024-09-25 19:12:57