Does .NET support the promotion of Int32 to Int64 for arithmetic on 64-bit architectures?

I read this post and I was wondering if the CLR converts bytes and Int16 to Int32 for arithmetic, does it convert all bytes, Int16 and Int32 to Int64 when working in 64-bit mode?

Edit: Since the following loop:

for (short i = 0; i < 10; i++) {
    // ...
}

will create something like this in IL:

Int16 i = 0;
LOOP:
    Int32 temp0 = Convert_I16_To_I32(i); // !!!
    if (temp0 >= 10) goto END;
    ...
    Int32 temp1 = Convert_I16_To_I32(i); // !!!
    Int32 temp2 = temp1 + 1;
    i = Convert_I32_To_I16(temp2); // !!!
    goto LOOP;
END:

Will the following loop:

for (int i = 0; i < 10; i++) {
    // ...
}

To produce something similar on 64-bit architectures?

Int32 i = 0;
LOOP:
    Int64 temp0 = Convert_I32_To_I64(i); // !!!
    if (temp0 >= 10) goto END;
    ...
    Int64 temp1 = Convert_I32_To_I64(i); // !!!
    Int64 temp2 = temp1 + 1;
    i = Convert_I64_To_I32(temp2); // !!!
    goto LOOP;
END:
+4
source share
1 answer

, CLR : #. , CLR Byte Int16, , Byte Int16 (Int32).

. # Int32, IL. VB.NET , , IL : Int32, , , Int32.

, . # , , Int32. CLR , Int32 4 , : CLR native int, . # , unsafe.

/unsigned variancy

P.P.S. IntPtr , : IntPtr.Size 4 32 8 64-

+3

All Articles