Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



Share:
Notifications
Clear all

[Solved] Lazarus - cint or integer to boolean

1 Posts
1 Users
0 Reactions
3,990 Views
 Hans
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter  

Sometimes, especially when using C-libraries, a function may return an integer or a cint (C-integer) where one would expect a boolean.

To convert this integer value to a boolean, a few facts first;

The value for "False" is typically stored as 0 (zero),
and the value for "True" is typically anything else (non-zero).

Note:
Most of the time "True" returns as "-1" which is because the Boolean data type is stored as a 16-bit signed integer.
In this construct −1 (true) evaluates to 16 binary 1's (11111111 11111111),
and 0 (false) as 16 binary 0's (00000000 00000000 - the Boolean value False). 


   
ReplyQuote
Share: