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.

DarkBASIC Discussion / The max number that DarkBASIC recognises before errorring out.

Author
Message
Miketheman123
21
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 17th Dec 2006 01:56
I don't know if its just my computer or what not but DarkBASIC on my comp seems to error and glitch if presented with extremely big numbers. The max value that I think I can use without problems is 999,999,999. Anything above that brings back different, lower, higher or negative numbers. Any reasons for this or is 999999999 the biggest number DarkBASIC can recognise fully functionally.

Mike
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 17th Dec 2006 02:55
Integers in DBC are signed 32bit (1 bit is used for the sign) which gives them the range -2147483647 to 2147483647. (DBP has larger variable types).

Basically, if you use values greater than 2147483647 then you end up with a negative number.

For example, if you try the following snippet:

A = 2147483648
Print A
Wait Key

all 32 bits are used (the sign bit is tripped) and you get a negative number.

TDK_Man

NA170425
User Deleted
Posted: 17th Dec 2006 04:04
That's happening because variables don't have enough memory to hold very large numbers. Take this dword for example:

11111111 11111111 11111111 11111110

When you increment it, it becomes this:

11111111 11111111 11111111 11111111

Now it is compeletly full, if you increment it again, it will become this:

1 00000000 00000000 00000000 00000000

However, that extra bit is simply tossed out, and the dword is interpred like this:

00000000 00000000 00000000 00000000

Which is 0 in decimal.

Kyhoshi
18
Years of Service
User Offline
Joined: 21st Jun 2006
Location: Somewhere over the rainbow.
Posted: 22nd Dec 2006 03:56
what happens if a object manages to get to that point in 3d space?

(\__/)
(O.o )
(> < ) This is Bunny. Copy Bunny into your signature to help him on his way to world domination!
NA170425
User Deleted
Posted: 22nd Dec 2006 21:05
You'll never need to worry about that, I'm sure no 3d world is that big.

I tried doing that once just to see what happened. 3d objects store their positions as floats, and since floats can hold numbers like undefined and infinity, weird stuff happens. My text statements told me the object was positioned at (infinity, infinity, infinity) and I was stuck there no matter how fast I tried to move away.

infinity + 100000 = infinity

"Did I ever tell you how I got the nickname the Dragon of the West?"
"I'm not interested in a lengthy anecdote, Uncle."
"It's more of a demonstration really."

Login to post a reply

Server time is: 2025-05-26 03:48:39
Your offset time is: 2025-05-26 03:48:39