Why don't underscores in numbers enforce proper formatting?
Era Scarecrow
rtcvb32 at yahoo.com
Thu Mar 7 15:39:53 PST 2013
On Thursday, 7 March 2013 at 06:31:39 UTC, Simen Kjærås wrote:
> On Wed, 06 Mar 2013 22:06:42 +0100, ixid <nuaccount at gmail.com>
> wrote:
>
>> The underscores in values such as 1_000_000 aid readability
>> but DMD doesn't see anything wrong with any placement of
>> underscores as long as they follow a number. Is there any
>> reason to allow uses like 1_00_000, which are typos or
>> exceedingly lazy modifications of value, and not enforce
>> digits to form sets of three after the first underscore?
>
> In addition to the examples given by Simen and Adam, China and
> Japan place digits in groups of 4 (10 0000 0000), while India
> uses groups of 2 (10 00 00 00).
Seems enforcing underscores to a particular number would be a
bad thing. Unless you could specify the width of them so it would
do a side check to confirm it fits a particular format, but it
would then clutter the code perhaps?? Hmmm..
However using underscores it's less likely to make silly
mistakes since you mentally can count and tell the groups are in
2's, 3's, 4's or 5's fairly easily.
More information about the Digitalmars-d-learn
mailing list