Actual bit sizes in Unity for [char, short, int, float and boolean] (Windows, C#)

I thought I’d do some research on variable Type sizes before starting to program my Network.
But hell, is it confusing…
What I learned so far: it seems to be platform and language dependant.

I found varying informations about it on Wikipedia,
where a short data type for example, could range from 2 bit to 16 bit…
https://en.wikipedia.org/wiki/Integer_(computer_science)

#1 So does anyone know more about this mysterious voodoo (How can I test it)?
(How many bits does a char, short, int, float, boolean actually use up in Unity 3D, C# ?)

#2 Does it even work this way ?
Or doesnt it make any difference at all to try to send smaller data Types over Unet
(e.g. ushort instead of int, ect…) ?

#3 Does it differ from target platform to target platform ?
What if a Linux user joins a Windows users lobby ?

Could a programming god descent from his heavenly realm and clear things up for a nooby ?
Thanks ! :slight_smile:

Nothing is smaller than a byte. Find out exact sizes with sizeof() :slight_smile:

The different datatypes should be the same across all operating systems. If they’re not I want to kick someone.

Oh WOW ! That was fast and easy, thank you orb !
I also noticed that my confusion mainly came simply from misreading the wiki page…
short was listed with 16bit, and again further down as 2byte. my bad,
but you cleared things up for me big time, thank you ! I lack a good education in computer science.

For anyone in the future whos as nooby as I was; Heres a quick overview:

boolean : 1byte

byte : 1byte (obviously)
short : 2bytes
int : 4bytes
long : 8bytes

char : 2bytes

float :4bytes
double :8bytes

4 Likes