Re: boolean values


[ Follow Ups ] [ BasicCard User Forum ]

Posted by zeitcontrol (80.130.201.128) on September 03, 2004 at 06:24:00:

In Reply to: boolean values posted by sivaram on June 28, 2004 at 03:51:12:

Boolean values are not generally handled equals across all platforms/programming systems.
Most uses 0 for value "false" and a value different to 0 for value "true". There are different possibilities like using "1" -> "0x01" or "-1" (aka 255 for unsigned char values) -> "0xff".
If there are no explicit boolean type this might embed some pitfalls.

BasicCard basic uses true/false as a substitution for true = 255 (signed == -1) and false = 0. These are integer values since BasicCard do not know a real boolean type.
(results of some comparison are of type boolean but this is only
a special version of integer type)

using true/false in compare lead to different results as
using boolean operation.

if cmpval = true then
end if

will be expanded to

if cmpval = &hff then
end if

comparison will work only if cmpval is of value 0xff (which might
be true if it is the some boolean compare before.)

if cmpval then
end if

will be expanded to

if cmpval 0 then
end if

comparision will work as long a the cmpval is a value different to
zero.

Juergen Mengeling, ZeitControl cardsystems


Follow Ups:


[ Follow Ups ] [ BasicCard User Forum ]