C#C
C#2y ago
14 replies
Moods

how Int32 etc. store their values

So we know that stuff like Int and long is just a sequence of bits with the length depending on the data type. I wanted to know at what level is this conversion to binary being done

like if I have
int foo = 90;
Console.WriteLine(foo);


To my knowledge this 90 is converted to its 32-bit binary equivalent and stored then, and when you’d want to read from that variable (I’m assuming correct me if I’m wrong) this binary is then converted to its decimal equivalent and then displayed with the WriteLine function.

I just wanted to know is this conversion done at a hardware level (like how processors have instructions built in) or is it done by the compiler. And what of the case with negative numbers because those have to be stored as two’s complements too
Was this page helpful?