[fpc-devel] Extended($FFFFFFFFFFFFFFFF) = -1?

Ewald ewald at yellowcouch.org
Fri Feb 28 21:07:41 CET 2014


On 28 Feb 2014, at 20:39, Jonas Maebe wrote:

> On 28 Feb 2014, at 20:21, Ewald wrote:
> 
>> Since I was curious as to the intended-ness of this behaviour I wrote the second set of tests which show me that this is not true for longwords: both 3 & 4 give the same result. This lead me to the conclusion that this is a bug. Shall I file it?
> 
> All hexadecimal constants are (conceptually) parsed as int64, so this is by design. int64($00000000ffffffff) is not -1.

So all numeric constants that are not floats are parsed as Int64's?

Isn't that view about numeric constants a bit limited (why an Int64 for example, you could've picked a virtual Int256 just as well)? Especially if you have a data type that can contain the number in it's original intention? Delphi compatibility I read in the bug report you mentioned, and I understand that in mode delphi (see below though for a bit of `issues`), but the example program is in mode fpc (or how is it called?). Can that at least be called a bug (in the documentation at the very least)?

By the way, what do you do when you want to port fpc to a one's comlement machine (if they still exist)? Is $FFFF FFFF FFFF FFFF equal to 0 then? And when you have a CPU that has a native integer size of 128 bit, how do you do the transformation then? Just truncate the constant to a 64 bit wide integer? Admitted, it are rare cases...

--
Ewald




More information about the fpc-devel mailing list