[fpc-pascal] wiki page confusion with Ordinal to Word conversion
Ben
ben.smith.lists at gmail.com
Fri Mar 11 11:41:39 CET 2011
Hi,
http://wiki.freepascal.org/User_Changes_2.4.0#Byte.2FWord.2FLong.2FQwordbool_types
Based on this wiki description, If a value of Ord(True) is assigned to
say a Word variable, the value of that Word variable is now -1. How is
that possible when the Word type has a valid range of only 0..65535??
Windows / Delphi compatibility or not, this change makes NO sense
because the new behaviour is a value that is simply out of range for
Byte, Word, Long and QWord.
Creating a quick test application shows that the 2.4.3 compiler still
functions correctly. The output of this program is "1" - the expected
behaviour.
But the wiki comment seem contradictory to that:
“Assigning true to such variables now sets them to "-1"”
Is that a typo in the wiki?
----------------------------------
program test;
var
w: word;
bo: Boolean;
begin
bo := True;
w := Ord(bo);
writeln(w);
end.
----------------------------------
--
Ben.
More information about the fpc-pascal
mailing list