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.

AppGameKit Classic Chat / Variable Range

Author
Message
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 29th Jan 2020 04:13 Edited at: 29th Jan 2020 04:14
Noting the published Ranges for Integers and Reals:


...i wanted to see what would happen if i (mis?)used datatypes while setting sprite position:


running that, you'll see that the DiffX between CurrentX and SpriteX varies by a consistent +-64.

Then, if using CurrentX = CurrentX +1, instead, it reaches 2147483648, or 1 more than the Max (i think i saw a thread on this recently?) before it wraps to -2147483647 and continues adding.

This is (i believe) trivial but i am curious. Can anyone shed some light?

BTW, what brought me here is the question of sprite placement limits. IE, if i want to (conventionally) represent "space", how far can my ship travel?
nz0
AGK Developer
16
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 29th Jan 2020 10:51
Because you are using integers for sprite position, I would expect that the drift is going to include sub-pixel rounding (try it using SetSpriteSnap() to verify)

There's also a little bit of discrepancy with float precision - e.g. an integer of 1000 may well end up as 1000.00001, although there are ways to counter this.

I would welcome a few more numerical types - unsigned integers and floats for sure.
Byte and word would also be handy, as well as float types with different precision e.g. a# as Float(3) to specify 3 decimal places only - allowing bigger floats.

As for your actual question, you could use different units other than numbers - say integer 2147483647 = 1 squizzle, so you can travel 2147483647 squizzles before inventing another unit

Login to post a reply

Server time is: 2024-04-25 10:18:52
Your offset time is: 2024-04-25 10:18:52