<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic C compiler and BOOL_WIDTH in Intel® oneAPI DPC++/C++ Compiler</title>
    <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/C-compiler-and-BOOL-WIDTH/m-p/1571045#M3504</link>
    <description>&lt;P&gt;I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Intel(R) oneAPI DPC++/C++ Compiler for applications running on Intel(R) 64, Version 2024.0.2 Build 20231213&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;icx -Qstd=c2x myfile.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The standard C23 (still in drat mode, we have to say),&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;introduces the macro BOOL_WIDTH in &amp;lt;limits.h&amp;gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far I understand, the suffix _WIDTH for every constant appearing&lt;/P&gt;&lt;P&gt;in ISO standards of C language&amp;nbsp;&lt;/P&gt;&lt;P&gt;refers to the number of "value bits" of the corresponding data type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(a) The compiler reports a value of BOOL_WIDTH == 8.&lt;/P&gt;&lt;P&gt;(b) On the other hand, sizeof(bool) == 1.&lt;/P&gt;&lt;P&gt;(c) However, the unique values that one can store in an object of type 'bool' are 0 and 1.&lt;/P&gt;&lt;P&gt;By the conditions (a) and (b) I conclude that there is not room for trap representation.&lt;/P&gt;&lt;P&gt;Thus, there are 256 effective choices of bit values to represent the values 0 and 1.&lt;/P&gt;&lt;P&gt;In this way, the type 'bool' is using many different internal representations (in terms of bits) in order to store the same mathemical value.&lt;/P&gt;&lt;P&gt;My doubt here is which combinations of bits should represent the boolean value 'zero' and which combinations of bits are used to represent the value 'one'.&lt;/P&gt;&lt;P&gt;I am guessing that every combination of bits containing at least one bit flagged to 1 is used to represent the boolean value 'one' and that 'zero' is represented only with the combination of bits containing all bits set to 0.&lt;/P&gt;&lt;P&gt;But I don't know if such a behaviour is well documented.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 09 Feb 2024 16:26:00 GMT</pubDate>
    <dc:creator>Semphalk</dc:creator>
    <dc:date>2024-02-09T16:26:00Z</dc:date>
    <item>
      <title>C compiler and BOOL_WIDTH</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/C-compiler-and-BOOL-WIDTH/m-p/1571045#M3504</link>
      <description>&lt;P&gt;I am using:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Intel(R) oneAPI DPC++/C++ Compiler for applications running on Intel(R) 64, Version 2024.0.2 Build 20231213&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am running:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;icx -Qstd=c2x myfile.c&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The standard C23 (still in drat mode, we have to say),&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;introduces the macro BOOL_WIDTH in &amp;lt;limits.h&amp;gt;.&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far I understand, the suffix _WIDTH for every constant appearing&lt;/P&gt;&lt;P&gt;in ISO standards of C language&amp;nbsp;&lt;/P&gt;&lt;P&gt;refers to the number of "value bits" of the corresponding data type.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(a) The compiler reports a value of BOOL_WIDTH == 8.&lt;/P&gt;&lt;P&gt;(b) On the other hand, sizeof(bool) == 1.&lt;/P&gt;&lt;P&gt;(c) However, the unique values that one can store in an object of type 'bool' are 0 and 1.&lt;/P&gt;&lt;P&gt;By the conditions (a) and (b) I conclude that there is not room for trap representation.&lt;/P&gt;&lt;P&gt;Thus, there are 256 effective choices of bit values to represent the values 0 and 1.&lt;/P&gt;&lt;P&gt;In this way, the type 'bool' is using many different internal representations (in terms of bits) in order to store the same mathemical value.&lt;/P&gt;&lt;P&gt;My doubt here is which combinations of bits should represent the boolean value 'zero' and which combinations of bits are used to represent the value 'one'.&lt;/P&gt;&lt;P&gt;I am guessing that every combination of bits containing at least one bit flagged to 1 is used to represent the boolean value 'one' and that 'zero' is represented only with the combination of bits containing all bits set to 0.&lt;/P&gt;&lt;P&gt;But I don't know if such a behaviour is well documented.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Feb 2024 16:26:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/C-compiler-and-BOOL-WIDTH/m-p/1571045#M3504</guid>
      <dc:creator>Semphalk</dc:creator>
      <dc:date>2024-02-09T16:26:00Z</dc:date>
    </item>
    <item>
      <title>Re: C compiler and BOOL_WIDTH</title>
      <link>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/C-compiler-and-BOOL-WIDTH/m-p/1587450#M3629</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/337685"&gt;@Semphalk&lt;/a&gt;&amp;nbsp;can you please provide&amp;nbsp;&lt;SPAN&gt;myfile.c?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Apr 2024 19:19:34 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-oneAPI-DPC-C-Compiler/C-compiler-and-BOOL-WIDTH/m-p/1587450#M3629</guid>
      <dc:creator>Alex_Y_Intel</dc:creator>
      <dc:date>2024-04-08T19:19:34Z</dc:date>
    </item>
  </channel>
</rss>

