www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.DMDScript

c++ - bool behaviour still char (DM 8.29n)

Source:

#include <stdio.h>

bool flags[sizeof(unsigned long) * 8];

void main()
{
    unsigned long l = 0xffffffffL;

    printf("sizeof(bool) = %d\n", sizeof(bool));

    for (int i = 0; i < sizeof(unsigned long) * 8; i++)
        flags[i] = l & (1 << i);

    for (int i = 0; i < sizeof(unsigned long) * 8; i++)
        printf("%d %d\n", i, flags[i]);
}


Output:

sizeof(bool) = 1
0 1
1 2
2 4
3 8
4 16
5 32
6 64
7 -128
8 0
9 0
10 0
11 0
12 0
13 0
14 0
15 0
16 0
17 0
18 0
19 0
20 0
21 0
22 0
23 0
24 0
25 0
26 0
27 0
28 0
29 0
30 0
31 0
Aug 06 2002