01777777777777777777777 [std.conv.octal]

Steven Schveighoffer schveiguy at gmail.com
Thu Apr 7 22:53:15 UTC 2022


On 4/7/22 4:52 PM, kdevel wrote:
> On Thursday, 7 April 2022 at 19:59:24 UTC, Steven Schveighoffer wrote:
> [...]
>>> The method does not work for most of the possible octal literals 
>>> whose values fit in a ulong. I would call it an inconvenience method.
>>
>> It works for all numbers below 288,230,376,151,711,744 (i.e. up to 58 
>> bits).
>>
>> So, yeah, not all of them. But many of them.
> 
> For the record: 1 - 2^54 / 2^64 = .9843. I.e. for 98.4 % of all possible 
> values fitting in a ulong ```template octal (alias decimalInteger)``` 
> does **not** work.

Please tell me the percentage of octal literals written in code 
(including all C code) that are in that range.

Remember, these are *literals*, not values that are in memory.

>> [...]
>> We might want to just undocument the integer version.
> 
> I strongly recommend deprecation and removal. Imagine what happens if 
> someone  forgets to type the quotation marks and gets a type which is 
> wider than expected.

No imagination required -- compiler error.

> The abolishment of the leading-zero octals shall 
> not introduce another error category.

Who cares? It's a compiler error if it doesn't work.

-Steve


More information about the Digitalmars-d mailing list