Re: request for change of boolean

new topic     » goto parent     » topic index » view thread      » older message » newer message

Kat wrote:
>  From Turbo Pascal v6 Programmer Guide (oem hardcopy) book, 
> page 24: ....Boolean is an enumerated type ....
> page 218: .... An enumerated type is stored as an unsigned byte if the
> enumeration
> has 256 or fewer values; otherwise, it is stored as an unsigned word.
> 
> In other words, it cannot be negative.

I realize that you already know this but for the benefit of onlookers, the above
description is talking about how boolean values have been implemented in Turbo
Pascal - that is, their actual bit representation in RAM. It is not talking about
the semantics of booleans, which deals with how they can be used and what they
mean to a program.

The TP manual is stating that booleans cannot never be repesented in RAM as
negative numbers.

> Ergo, if a boolean compare result is
> negative, it's an error or it's stored as zero, or FALSE.

This is where we part company though. I do not see the necessary logical
connection between the manual's statements and your conclusion. I suspect that
when negative numbers are converted to boolean before such a comparision, TP
converts zero to false and all other values to true.

Here is a small Pascal demo program ...

=================
program booltest;

var
  remainder: Boolean;

begin
  remainder := Boolean(-1);
  if remainder then
      Writeln('-1 is true')
  else
      Writeln('-1 is false');

  remainder := Boolean(1);
  if remainder then
      Writeln('1 is true')
  else
      Writeln('1 is false');      

  remainder := Boolean(0);
  if remainder then
      Writeln('0 is true')
  else
      Writeln('0 is false');      

end.

==========

This gives the result :

-1 is true
1 is true
0 is false


-- 
Derek Parnell
Melbourne, Australia
Skype name: derek.j.parnell

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu