I wrote a small function to convert MB to Bytes, however, there seems to be a bug in int64. According to the documentation, int64 ranges from -9223372036854775808 to 9223372036854775807, but my results differ...a lot:
Const FreeSpace = 67100;
var FreeSpaceConverted :int64;
.
.
.
FreeSpaceConverted := FreeSpace shl 20;
Using a value of 67100 for FreeSpace results in a value of 1639972864 instead of 70359449600. It's obvious that the conversion ran out of space and wrapped around. The actual size of int64 seems to be 70359449600 - 1639972864 = 68719476736 = 2^36 while it should be 2^63-1. An exponent of 36 looks rather strange. Could it be a number twist in the compiler itself??
Also, using the following alternative gives the error "Overflow in conversion or arithmetic operation" even though it shouldn't:
FreeSpaceConverted := FreeSpace * 1024 * 1024;
On the other hand, the following alternative does work:
FreeSpaceConverted := FreeSpace * 1024;
FreeSpaceConverted := FreeSpaceConverted * 1024;
Is this normal behavior and if so, what's the reason for all of this?