Regarding the proposed Binray Literals Deprecation
Steven Schveighoffer
schveiguy at gmail.com
Wed Sep 14 02:56:59 UTC 2022
On 9/13/22 8:35 PM, Walter Bright wrote:
> On 9/13/2022 2:04 PM, Steven Schveighoffer wrote:
>>> 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?
>>
>> How do you know the purpose is to fill up an int?
>
> Ok, I'll rephrase that. How do you know when to stop?
Because I'm done making the mask. In this specific situation, I'm only
testing 9 bits.
0b100100100 // obvious, clear, easy
0x? // have to calculate using 0b numbers *hint: it's not 924*
> There's a reason hex is so ubiquitous. It's compact. Binary literals
> beyond a few digits (8 max) are more or less unreadable. Yes, the _ can
> extend it to more digits before it becomes unreadable. (Even long hex
> numbers benefit from _, again, after 8 digits.)
But it doesn't disprove the fact that *sometimes*, hex digits aren't as
clear.
1) binary numbers are sometimes clearer given the context
2) binary numbers *already* are a thing in D
3) there is no ambiguity with a binary number literal. The `0b` prefix
is obvious.
-Steve
More information about the Digitalmars-d
mailing list