Regarding the proposed Binray Literals Deprecation

Max Samukha maxsamukha at gmail.com
Sat Sep 10 08:19:18 UTC 2022


On Saturday, 10 September 2022 at 02:22:53 UTC, Walter Bright 
wrote:

> Hex values are far easier to read, too. Have you ever put the 
> tip of your pencil on the screen to count the number of 1's? I 
> have. Binary literals are user unfriendly.

Bit flags are easier to read as binary grouped in nibbles. For 
example:

enum ubyte[16] ledDigits =
     [
         0b0011_1111, // 0
         0b0000_0110, // 1
         0b0101_1011, // 2
         0b0100_1111, // 3
         0b0110_0110, // 4
         0b0110_1101, // 5
         0b0111_1101, // 6
         0b0000_0111, // 7
         0b0111_1111, // 8
         0b0110_1111, // 9
         0b0111_0111, // A
         0b0111_1100, // b
         0b0011_1001, // C
         0b0101_1110, // d
         0b0111_1001, // E
         0b0111_0001, // F
     ];

Those are the bit masks for a 7-segment display. Of course, you 
could define them by or'ing enum flags or translating into hex, 
or use a template, but that would be annoying.


More information about the Digitalmars-d mailing list