Forum > General
div bug with int64 on Win32?
gja822:
Free Pascal Compiler version 3.0.0 [2015/11/16] for i386
Copyright (c) 1993-2015 by Florian Klaempfl and others
Target OS: Win32 for i386
(Vista Home Premium)
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---Uses sysutils;Var dd: int64; Begindd:=$FF11813BCCC3B114;WriteLn('FF11813BCCC3B114:00000000002B1100='#9, IntToHex(dd div int64($00000000002B1100),16));WriteLn('FF11813BCCC3B114:00000000002B1100='#9, IntToHex(int64($FF11813BCCC3B114) div int64($00000000002B1100),16))End.
output is:
FF11813BCCC3B114:00000000002B1100= 0000000589B05C36
FF11813BCCC3B114:00000000002B1100= FFFFFFFA764FA3CA
That is, div loses sign with int64.
Is it a bug, or I should use another operator or newer version?
Thaddy:
That's a bug in the 386 compiler indeed.
Here's first 64 bit then 32 bit:
C:\Kol64>fpc -Mdelphi rc.dpr
C:\Kol64>rc
FF11813BCCC3B114:00000000002B1100= FFFFFFFA764FA3CA
FF11813BCCC3B114:00000000002B1100= FFFFFFFA764FA3CA
FF11813BCCC3B114:00000000002B1100= FFFFFFFA764FA3CA
C:\Kol64>ppc386 -Mdelphi rc.dpr
C:\Kol64>rc
FF11813BCCC3B114:00000000002B1100= 0000000589B05C36
FF11813BCCC3B114:00000000002B1100= FFFFFFFA764FA3CA
FF11813BCCC3B114:00000000002B1100= FFFFFFFA764FA3CA
Given a slightly modified example:
--- Code: Pascal [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---program rc;{$APPTYPE CONSOLE}{$IF DEFINED(FPC)}{$MODE DELPHI}{$IFEND}{$RANGECHECKS ON}uses sysutils;Var dd: int64;Begindd:=$FF11813BCCC3B114;WriteLn('FF11813BCCC3B114:00000000002B1100='#9, IntToHex(dd div int64($00000000002B1100),16));WriteLn('FF11813BCCC3B114:00000000002B1100='#9, IntToHex(int64($FF11813BCCC3B114) div int64($00000000002B1100),16));WriteLn('FF11813BCCC3B114:00000000002B1100='#9, IntToHex(int64($FF11813BCCC3B114 div $00000000002B1100),16));Readln;End.
Note Delphi throws an error for DD: constant expression violates subrange bounds.... Both XE2 64/32 and D2007
tk:
In my Delphi XE works correctly, is FPC bug.
EDIT: I have no range check error.
Thaddy:
--- Quote from: tk on May 22, 2016, 10:56:21 am ---In my Delphi XE works correctly, is FPC bug.
--- End quote ---
Try my example. Range checks should be on.
XE2:
C:\Kol64>dcc64 -Asysutils=system.sysutils rc.dpr
Embarcadero Delphi for Win64 compiler version 23.0
Copyright (c) 1983,2011 Embarcadero Technologies, Inc.
rc.dpr(8) Warning: W1012 Constant expression violates subrange bounds
rc.dpr(14)
15 lines, 0.78 seconds, 159444 bytes code, 54408 bytes data.
C:\Kol64>rc
Exception ERangeError in module rc.exe at 0000000000027D0D.
Range check error.
Thaddy:
--- Quote from: tk on May 22, 2016, 10:56:21 am ---In my Delphi XE works correctly, is FPC bug.
--- End quote ---
No. If it works in XE it is also an XE bug ;) These things happen you know.... It does not work in D7,D2007,XE2 64/32.
That's why I put the range check in...
Navigation
[0] Message Index
[#] Next page