Boolean: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
No edit summary
(added info about memory size)
 
(9 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{otherlang2|
{{LanguageBar}}
ru = Boolean:ru}}A '''boolean''' value is either "on" or "off". When enabled it is denoted with <code>true</code> or <code>1</code>, and when disabled it is denoted with <code>false</code> or <code>0</code>.


[[Material]]s use 1 and 0. C++ code generally uses true and false.
 
A '''boolean''' value is a toggle used in programming that is inherently exclusively either "on" or "off". When ''enabled'' it is denoted with <code>true</code> or <code>1</code>, and with <code>false</code> or <code>0</code> when ''disabled'', depending on the syntax of the language being used.
 
Its use varies in different areas of the engine:
 
* C++ code ''generally'' uses <code>true / false</code>, which occupies 1 [[byte]].
* The unmodified {{hl|2}} SDK uses <code>BOOL</code> to represent boolean values, it is a typedef for <code>int</code>; therefore it uses 4 bytes instead of 1.
* [[Material]]s use <code>1 / 0</code>
* [[Weapon script|Weapon Scripts]] use <code>1 / 0</code>
* [[VMF|.VMF]] files use <code>1 / 0</code>
* [[DMX|.DMX]] files {{todo|Verify how, and which form}}
* [[VCD|.VCD]] files use <code>1 / 0</code>
 
Certain file types used in Source also do not ''typically'' use booleans:
* [[QC|.QC]] files
* [[Studiomdl Data|.SMD]] files


[[Category:Glossary]]
[[Category:Glossary]]

Latest revision as of 14:49, 28 May 2025

English (en)Deutsch (de)Español (es)Hrvatski (hr)Русский (ru)中文 (zh)Translate (Translate)


A boolean value is a toggle used in programming that is inherently exclusively either "on" or "off". When enabled it is denoted with true or 1, and with false or 0 when disabled, depending on the syntax of the language being used.

Its use varies in different areas of the engine:

  • C++ code generally uses true / false, which occupies 1 byte.
  • The unmodified Half-Life Half-Life SDK uses BOOL to represent boolean values, it is a typedef for int; therefore it uses 4 bytes instead of 1.
  • Materials use 1 / 0
  • Weapon Scripts use 1 / 0
  • .VMF files use 1 / 0
  • .DMX files
    Todo: Verify how, and which form
  • .VCD files use 1 / 0

Certain file types used in Source also do not typically use booleans: