Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2011-03

wiki page confusion with Ordinal to Word conversion

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Ben

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.
Jonas Maebe
to Ben
Ben wrote
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??

byte/word/long/qwordbool is used as a shorthand for bytebool, wordbool, longbool, qwordbool. Try this:

program test;
var
 w: word;
 bo: wordbool;
begin
 bo := True;
 w := ord(bo);
 writeln(w);
end.

Jonas

Ben
to Jonas Maebe

Op 2011-03-11 13:14, Jonas Maebe het geskryf:

byte/word/long/qwordbool is used as a shorthand for bytebool, wordbool, longbool, qwordbool.

Ah, then I did not understand the wiki correctly. I read it as types Byte, Word, Long etc... except for the last one which was QWordBool.

Thanks for explaining Jonas.

Ben.