Repository navigation
Boolean
Home › Standard Data Types › Boolean
Standard data type
Dim variable As BooleanBoolean data type. Can hold the values True or False
Default value on initialization is False
Notes on definition of boolean data type:
*- Ideally, the definition of the boolean data type is that it holds the value of True or False, and that's it. However, to make this concept a reality, we need a definition that uses real world connections.
- A more realistic definition is that the boolean data type is a 1-bit integer, having the value 0 to indicate
Falseand 1 to indicateTrue. - For a practical definition, we must consider, yet again, additional factors. The most significant factor is that the hardware (processor) on which code is executed does not directly support a 1-bit data type; the smallest register or memory size we can work with is 8-bits or 1-byte.
- Assume "false" is 0 in both C/C++ and FB. C/C++ has logical 'not' operator '!' such that '!0' produces '1'. FB has a bitwise
Notoperator such that 'not 0' produces '-1'. - Nevertheless the definition under the hood for a FB boolean remains an 1-bit integer, zero extended to fill larger integer types.
- Therefore when assigning a boolean with an integer value (by implicit conversion and not with the
FalseorTruevalue), '0' induces theFalsestate and '1' or '-1' induces theTruestate (any other value also induces theTruestate, but with a warning message). - Otherwise when assigning a numeric type with a boolean (by implicit conversion),
Falseinduces the '0' value andTrueinduces the '-1' value. - However, the purpose and intent of the boolean data type remains, that it should only ever hold a
Truevalue orFalsevalue, regardless of the underlying details.*
- Not available in the -lang qb dialect unless referenced with the alias
__Boolean.
- New to FreeBASIC
Dim boolvar As Boolean
boolvar = True
Print "boolvar = ", boolvarOutput:
boolvar = trueCategory: Standard Data Types
Kind: keyword
Reproduced from the FreeBASIC Wiki Manual under the GNU Free Documentation License 1.3 — with no Invariant Sections, no Front-Cover Texts and no Back-Cover Texts. Copyright © the FreeBASIC project and wiki contributors. See License.
tiko-lang · Home · Feature Index · Keyword Index · License
FreeBASIC manual pages reproduced under the GNU FDL 1.3.
- Home
- What Is tiko-lang
- Quick Start
- Installing on macOS
- Debugging
- Feature Index
- Compatibility
- FAQ
- AI Cheatsheet
- Generics
- Interfaces
- For Each
- Iterators
- Tuples
- Array Results
- Defer
- Lambdas
- Block Strings
- Partial Types
- String Slices
- Embed
- Typed Variadics
- C Header Import
- Foreign Library Linking
- UString
- Fixed-Width Types
- Nullptr
- String Library
- Format
- Array
- Map
- Set
- LinkedList
- OrderedMap
- OrderedSet
- Sorting
- Optional
- Result
- Smart Pointers
- Date and Time (Chrono)
- Time Zones
- Filesystem
- File Streams
- Config (INI and TOML)
- Codec
- Hash
- UUID
- OS
- Process
- Net
- HTTP and TLS
- Math Library
- Finance
- Logging
- Terminal TUI Library
- PsControls
- tkControls
- sys/win
- Goroutines and Channels
- LLVM Backend
- tiko build
- TIKO_COMPILER
- Variable Declarations
- Standard Data Types
- User Defined Types
- Procedures
- Operators
- Control Flow Statements
- Converting Data Types
- Array Functions
- String Functions
- Mathematical Functions
- Bit Manipulation
- Date and Time Functions
- File I/O Functions
- Console Functions
- User Input (Runtime Library)
- User Input Functions (Graphics Library)
- Screen Functions
- 2D Drawing Functions
- Graphics Library Reference
- Graphics Keyword List
- Memory Functions
- Threading Support Functions
- Error Handling Functions
- Operating System Functions
- Preprocessor
- Intrinsic Defines
- Miscellaneous Keywords
- Modularizing