Regarding the proposed Binray Literals Deprecation
H. S. Teoh
hsteoh at qfbox.info
Tue Sep 13 21:01:39 UTC 2022
On Tue, Sep 13, 2022 at 01:43:44PM -0700, Walter Bright via Digitalmars-d wrote:
> On 9/13/2022 1:06 PM, Steven Schveighoffer wrote:
> > If I wanted to specify an "every third bit set" mask, in hex it would be
> > `0x924924924...`. But in binary it is `0b100100100100...`. The second
> > version is immediately clear what it is, whereas the first is not.
>
> Is it? How do you know it didn't overflow the int and create a long?
> How do you know you filled up the int?
[...]
Simple, use `_`:
0b1001_0010_0100
This makes it immediately obvious exactly how many bits the literal
occupies.
T
--
Javascript is what you use to allow third party programs you don't know anything about and doing you know not what to run on your computer. -- Charles Hixson
More information about the Digitalmars-d
mailing list