digitalmars.D - Typo in Types page
- Gustavo (2/2) Apr 06 2014 In the page http://dlang.org/type.html I believe there is a typo
- Philpax (8/10) Apr 06 2014 While a boolean is by definition a single bit, it is represented
- Kelet (10/12) Apr 06 2014 I don't think it's a typo. Memory is typically byte-addressable
- Andrej Mitrovic (2/4) Apr 06 2014 static assert(byte.sizeof == 1); // 1 *byte*
- Marco Leise (6/11) Apr 07 2014 static assert(bool.sizeof == 1); // 1 *byte*
- Andrej Mitrovic (2/4) Apr 07 2014 LOL!
In the page http://dlang.org/type.html I believe there is a typo stating that bool is 1 byte instead of 1 bit.
Apr 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.
Apr 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. [2]: http://dlang.org/library/std/bitmanip/BitArray.html
Apr 06 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*
Apr 06 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:static assert(bool.sizeof == 1); // 1 *byte* There I fixed it ;) -- MarcoIn 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*
Apr 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!
Apr 07 2014