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!
[Solved] Lazarus - cint or integer to boolean
Delphi, Lazarus, Free Pascal
(@hans)
Famed Member Admin
Joined: 12 years ago
Posts: 2859
Topic starter
April 18, 2019 2:28 AM
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).