Welcome Guest [Log In] [Register]
Welcome to the Flamefusion forums. We hope you enjoy your visit.


You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Being able to request Flamefusion software for free, and get it made entirely free, covering your needs!

Being able to submit bug-reports or feature requests to our staff!

Get free support for any computer related subjects, including programming, in all .NET based languages!

Meet other programmers, and team up!

Username:   Password:
Locked Topic
[SOLVED] Use "Byte" instead of "Integer"?; What's better to use?
Topic Started: Jul 6 2009, 01:45 PM (52 Views)
[FF] Rene2

Hey,

I was wondering, if I'm using a number below 226 (Since a Byte can contain 0 trough 255), would it be better to use a byte data type? I've searched on google, and found out that a byte is 1 byte large, and an integer 4 bytes.

The difference would be really minor, but I still would like to know,

René.
Offline Profile Goto Top
 
[FF] Mathy
Member Avatar
Administrator
Rene2
Jul 6 2009, 01:45 PM
Hey,

I was wondering, if I'm using a number below 226 (Since a Byte can contain 0 trough 255), would it be better to use a byte data type? I've searched on google, and found out that a byte is 1 byte large, and an integer 4 bytes.

The difference would be really minor, but I still would like to know,

René.
Depends on several things.

Yes, you are correct. A byte takes less RAM. However, an Integer is also a 32 bit variable, meaning that it will run faster on a 32 bit processor.


Here's an example:

Short - 16 bit variable. Takes less RAM than an Integer, and runs faster on 16 bit processors (Non-existent these days).
Integer - 32 bit variable. Takes less RAM than a Long, and runs faster on 32 bit processors.
Long - 64 bit variable. Takes more RAM than both Short and Integer, and runs faster on 64 bit processors.

So if you're making operations in a long loop where thousands of executions are performed, you might want to save RAM. However, you may also sacrifice RAM to earn speed.

Ribcage uses Integers everywhere, since Incineration takes care of the unused variables. This makes it a little more speedy.

Thanks for using the forums.
Offline Profile Goto Top
 
[FF] Mathy
Member Avatar
Administrator
This topic has been marked as resolved.
Offline Profile Goto Top
 
[FF] Rene2

Mathy
Jul 6 2009, 10:09 PM
Rene2
Jul 6 2009, 01:45 PM
Hey,

I was wondering, if I'm using a number below 226 (Since a Byte can contain 0 trough 255), would it be better to use a byte data type? I've searched on google, and found out that a byte is 1 byte large, and an integer 4 bytes.

The difference would be really minor, but I still would like to know,

René.
Depends on several things.

Yes, you are correct. A byte takes less RAM. However, an Integer is also a 32 bit variable, meaning that it will run faster on a 32 bit processor.


Here's an example:

Short - 16 bit variable. Takes less RAM than an Integer, and runs faster on 16 bit processors (Non-existent these days).
Integer - 32 bit variable. Takes less RAM than a Long, and runs faster on 32 bit processors.
Long - 64 bit variable. Takes more RAM than both Short and Integer, and runs faster on 64 bit processors.

So if you're making operations in a long loop where thousands of executions are performed, you might want to save RAM. However, you may also sacrifice RAM to earn speed.

Ribcage uses Integers everywhere, since Incineration takes care of the unused variables. This makes it a little more speedy.

Thanks for using the forums.
Thanks! That helped me. Thanks for marking it as resolved. Was away today, so couldn't check it.
Offline Profile Goto Top
 
[FF] Mathy
Member Avatar
Administrator
You're welcome.
Offline Profile Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Get help · Next Topic »
Locked Topic

Theme created by tiptopolive. Find more great themes and skins at the ZB Theme Zone.