Thread overview
Typo in Types page
Apr 06, 2014
Gustavo
Apr 06, 2014
Philpax
Apr 06, 2014
Kelet
Apr 07, 2014
Andrej Mitrovic
Apr 07, 2014
Marco Leise
Apr 07, 2014
Andrej Mitrovic
April 06, 2014
In the page http://dlang.org/type.html I believe there is a typo stating that bool is 1 byte instead of 1 bit.
April 06, 2014
On Sunday, 6 April 2014 at 09:30:47 UTC, Gustavo wrote:
> In the page http://dlang.org/type.html I believe there is a typo stating that bool is 1 byte instead of 1 bit.

While a boolean is by definition a single bit, it is represented by programming languages as a byte for various reasons (including performance, data layout, and interfacing). You can verify that this is the case: http://dpaste.dzfl.pl/8129625be797

As far as I know, this is true for most, if not all, native programming languages. To actually store a value as a single bit, you will have to use bit manipulation.
April 06, 2014
On Sunday, 6 April 2014 at 09:30:47 UTC, Gustavo wrote:
> In the page http://dlang.org/type.html I believe there is a typo stating that bool is 1 byte instead of 1 bit.

I don't think it's a typo. Memory is typically byte-addressable and thus data types are either a byte or larger. Having a data type smaller than a byte means reading or writing to that variable will have to involve bit-twiddling operations which can make operations more expensive.

There are bitfields[1] and BitArrays[2] if you really need control of a data type on the bit level.

[1]: http://dlang.org/phobos/std_bitmanip.html#.bitfields
[2]: http://dlang.org/library/std/bitmanip/BitArray.html
April 07, 2014
On 4/6/14, Gustavo <gbuschle@hotmail.com> wrote:
> In the page http://dlang.org/type.html I believe there is a typo stating that bool is 1 byte instead of 1 bit.

static assert(byte.sizeof == 1);  // 1 *byte*
April 07, 2014
Am Mon, 7 Apr 2014 08:48:02 +0200
schrieb Andrej Mitrovic <andrej.mitrovich@gmail.com>:

> On 4/6/14, Gustavo <gbuschle@hotmail.com> wrote:
> > In the page http://dlang.org/type.html I believe there is a typo stating that bool is 1 byte instead of 1 bit.
> 
> static assert(byte.sizeof == 1);  // 1 *byte*

static assert(bool.sizeof == 1);  // 1 *byte*

There I fixed it ;)

-- 
Marco

April 07, 2014
On 4/7/14, Marco Leise <Marco.Leise@gmx.de> wrote:
> static assert(bool.sizeof == 1);  // 1 *byte*
>
> There I fixed it ;)

LOL!