Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

int behavior at 32/64 bit process?

I'm a process of 64 bit, my int size is 8 bytes.

I'm referencing a dll which is compiled to 32 bit.

This dll has a function which accepts an int parameter.

What will happen?

I'm sending a 8 byte to a 4 byte "container" ?

like image 622
Royi Namir Avatar asked Jun 12 '12 07:06

Royi Namir


People also ask

What is 32-bit and 64-bit integer?

A 32 bit Signed Integer can house a number from −2,147,483,648 to 2,147,483,647 Unsigned: 0 to 4,294,967,295. A 64 bit Signed Integer can house a number from −9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 Unsigned: 0 to 18,446,744,073,709,551,615.

Are ints 32 or 64-bit?

int is 32 bits in size. long , ptr , and off_t are all 64 bits (8 bytes) in size.

Can a'int be of 32 bits?

In 32-bit operating systems, the int type is usually 32 bits, or 4 bytes. Thus, the int type is equivalent to either the short int or the long int type, and the unsigned int type is equivalent to either the unsigned short or the unsigned long type, depending on the target environment.

What is the meaning of 32-bit and 64 bit processor?

32-bit means that a microprocessor can execute 4 bytes of data in one instruction cycle while 64-bit means that a microprocessor can execute 8 bytes of data in one instruction cycle. Since microprocessor needs to talk to other parts of computer to get and send data i.e. memory, data bus and video controller etc.


2 Answers

No, in 64-bit / C#, an int is still 4 bytes.

In C#, int is always merely an alias to global::System.Int32

What will change is the reference size and pointer size, but that is all abstracted by the IL anyway - nothing needs to change. Note, though, that the CLI is only going to be 32 bit xor (nand?) 64 bit. You might need one of them to be "Any CPU".

like image 69
Marc Gravell Avatar answered Sep 23 '22 01:09

Marc Gravell


It always maps to System.Int32 hence would be needing only 4

like image 23
V4Vendetta Avatar answered Sep 24 '22 01:09

V4Vendetta