Booleans
Displaying 1-4 of 4 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Kryptonite803

I feel a bit ridiculous asking, but I can't seem to find an answer in any documentation and have yet to find anything in the forums (though answers in the latter always seem to elude me).

Anyway, I'm designing my system with a series of flags that mark when a player has accomplished something. I remember starting verge and looking through the Sully files and looking through it again, even the flags array uses ints. Am I to assume that verge does not support booleans?

As I understand it, every integer uses 32 bits, but a boolean should only use 1 for on/off. I figured it would be more efficient to use booleans, or am I missing something in the bigger picture?

Let me know if I'm completely off my rocker and need to put my nose in the corner of disgrace.

Posted on 2009-07-28 09:20:30

Kildorf

Quote:Originally posted by Kryptonite803

I feel a bit ridiculous asking, but I can't seem to find an answer in any documentation and have yet to find anything in the forums (though answers in the latter always seem to elude me).

Anyway, I'm designing my system with a series of flags that mark when a player has accomplished something. I remember starting verge and looking through the Sully files and looking through it again, even the flags array uses ints. Am I to assume that verge does not support booleans?

As I understand it, every integer uses 32 bits, but a boolean should only use 1 for on/off. I figured it would be more efficient to use booleans, or am I missing something in the bigger picture?

Let me know if I'm completely off my rocker and need to put my nose in the corner of disgrace.

VergeC doesn't support booleans, you're right. Really you're fine to just use an int and consider 0 as "false" and anything else as "true". Basically, memory and disk space are so cheap that the trouble it would have been to implement a true boolean type would not have been worth it. Most C compilers use at least a full byte for booleans anyway, so unless Verge did its own special handling we wouldn't be saving anything.

There are ways to treat an int as 32 separate bits but seriously they're way more trouble than they're worth.

Posted on 2009-07-28 18:26:08 (last edited on 2009-07-28 18:26:33)

Kryptonite803

Quote:Originally posted by Kildorf

VergeC doesn't support booleans, you're right.

Good, at least I know I'm not crazy.

Basically, memory and disk space are so cheap that the trouble it would have been to implement a true boolean type would not have been worth it. Most C compilers use at least a full byte for booleans anyway, so unless Verge did its own special handling we wouldn't be saving anything.
Good point, and one that I was not even vaguely aware of. Again, I just want to make sure my programs are as efficient and compact as possible.

There are ways to treat an int as 32 separate bits but seriously they're way more trouble than they're worth.
I'll take your word for it.

I'll just scoot back into my corner and dress up a few of my ints like bools and everyone will be happy. Thanks for the info, it's much appreciated.

Posted on 2009-07-29 16:59:43

Goldengamer111

Sorry about responding to a somewhat old post, but I have #defined TRUE and FALSE to be one and zero respectively. I can then use the booleans instead of wondering if a certain slot can use more than two inputs. Despite what it says here, I don't think that they are built in (not sure about the newest build, though).

Posted on 2009-09-07 13:38:08


Displaying 1-4 of 4 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.