I had problems with the following code:
var FileSize : Int64; ... FileSize := Info.nFileSizeLow or (Info.nFileSizeHigh shl 32);
I expected it to work due to the type of Int64left side of the job. But this is not so. A partial calculation that shlappears to cause an overflow.
Int64
shl
So I changed it to:
FileSize := Info.nFileSizeLow or (Int64 (Info.nFileSizeHigh) shl 32);
which works on my 32 bit operating system but does not work on Vista 64 bit!
Finally,
FileSize := Info.nFileSizeHigh; FileSize := FileSize shl 32; FileSize := Info.nFileSizeLow or FileSize;
works on both systems.
Can someone explain the differences in these three versions?
a * b, a b Integer * - , Integer, , Integer. ( , , /.) , 64- , , 64- . , 64- 64- .
a * b
a
b
*
/
, 64- , . , 32- 64- ( ..); , .
, . , , , :
var a, b: Integer; // ... P((a shl 16) or b); // 32-bit operation or 64-bit operation?
, . , , . , 32- Windows, 64- Windows, .
, Delphi 7 " ":
Integer, 32- Longint. Int64 Int64. , .
:
var I: Integer; J: Int64; ... I := High(Integer); J := I + 1;
Int64 , Int64:
... J := Int64(I) + 1;
FileSize UInt64, Int64...
UInt64 ( Delphi) 64- , QWORD. FileSize ( , ?).
IMHO - UInt64, , :
FileSize := UInt64(Info.nFileSizeLow) or (UInt64(Info.nFileSizeHigh) shl 32));
Delphi 7 , .
FileSize := Info.nFileSizeLow or (Int64(Info.nFileSizeHigh) shl 32));
, , . asm- ( , Alt + F2) , . ...
( ) :
with Int64Rec(FileSize) do begin Lo := Info.nFileSizeLow; Hi := Info.nFileSizeHigh; end;
MSDN WIN32_FIND_DATA:
nFileSizeHigh: DWORD ., MAXDWORD.(nFileSizeHigh * (MAXDWORD + 1)) + nFileSizeLow.nFileSizeLow: DWORD .
nFileSizeHigh: DWORD .
, MAXDWORD.
(nFileSizeHigh * (MAXDWORD + 1)) + nFileSizeLow.
nFileSizeLow: DWORD .
FileSize := UInt64(Info.nFileSizeLow)+(UInt64(Info.nFileSizeHigh)*UInt64(1 shl 32));
, ...
, .
, Delphi , 64- , 32 . , -, 64- . , 64- , Delphi , 64- .
, (1) (2) , Delphi 32- 64- . , 32- - " " (.. , ). , COMPILED 32- 64- . , , CPU, , CPU, " ".
test for Delphi 7 and version 2 is fine. There must be a later error
Source: https://habr.com/ru/post/1791247/More articles:Javascript string for int array - javascriptUsing PHP odbc to grab varchar (max) column - phphow to compare Doctrine & Propel in symfony - phpHandling database changes / scripts in .NET? - .netWhat programming languages will allow me to manipulate the sequence of instructions in a method? - programming-languages | fooobar.comProblem with Boost.Filesystem - gccWhat size should Android notification icons have before Gingerbread HDPI? - androidCancel keyboard on Finish button on keyboard - iphoneImproving memory usage in an array to avoid block processing - pythonhow to get text inside html / text content? - javaAll Articles