tw27210.pp 567 B

12345678910111213141516171819202122232425262728293031
  1. {$mode delphi}
  2. program TestAbsolute; {$apptype console}
  3. function IsInt16 (L : longint) : boolean;
  4. var W : smallint absolute L;
  5. begin
  6. Result := longint (W) = L;
  7. end;
  8. function IsInt32 (Q : int64) : boolean;
  9. var L : longint absolute Q;
  10. begin
  11. Result := int64 (L) = Q;
  12. end;
  13. const VL1 : longint = -1;
  14. VL2 : longint = $12345678;
  15. VQ1 : int64 = -1;
  16. VQ2 : int64 = $123456781234;
  17. begin
  18. if not IsInt16 (VL1) then
  19. halt(1);
  20. if IsInt16 (VL2) then
  21. halt(2);
  22. if not IsInt32 (VQ1) then
  23. halt(3);
  24. if IsInt32 (VQ2) then
  25. halt(4);
  26. end.