octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Extending parser to accept '_' in numbers


From: Rik
Subject: Extending parser to accept '_' in numbers
Date: Mon, 5 Oct 2015 14:16:53 -0700

10/5/15

All,

I wrote a patch which allows numbers to use the underscore character for a
thousands separator, grouping, or just general legibility.  The code is
available on the patch tracker here
(https://savannah.gnu.org/patch/index.php?8760).  Quoting from the NEWS file,

 ** The parser has been extended to accept, but ignore, underscore characters
    in numbers.  This facilitates writing more legible code by using '_' as
    a thousands separator or to group nibbles into bytes in hex constants.
    Examples: 1_000_000 == 1e6 or 0xDE_AD_BE_EF

I ran 'make check' and there are no failing tests so I don't believe I
upset anything.  I put it on the patch tracker so it might get a little
more testing, but I'll commit it in a week or so if there are no problems.

The next thing I'd like to do is add support for binary constants.  It's
nice that Octave accepts hex constants '0x...', but working in electrical
engineering I often find that I would like to write a binary constant '0b...'

--Rik



reply via email to

[Prev in Thread] Current Thread [Next in Thread]