Re: [PATCH 00/15] lib: Add support for a decimal 0m prefix for numbers

Simon Glass
2021-07-20T15:58:17Z

Hi Tom,

On Tue, 20 Jul 2021 at 08:22, Tom Rini <trini@konsulko.com> wrote:
>
> On Tue, Jul 20, 2021 at 07:29:24AM -0600, Simon Glass wrote:
>
> > U-Boot mostly uses hex for value input, largely because addresses are much
> > easier to understand in hex.
> >
> > But in some cases a hex value is requested, but it is more convenient to
> > provide a decimal value. This may be because the value comes from another
> > source, where its base cannot be controlled.
> >
> > This series adds support for a 0m prefix to indicate a decimal number. The
>
> I _really_ don't want to invent something here. When the setexpr thread
> came up before I went and did a little digging. Per
> https://en.wikipedia.org/wiki/Radix the general way to express a number
> is (x)y where x is the number and y is the base (and y is in base10, and
> also a subscript). I thought it was a bit cumbersome for general use
> and didn't bring it up at the time.

Well I don't want to invent something either...but what to do?

So for example (10)123 would mean decimal 123? I don't know how we
would parse brackets separately from expressions though.

>
> If we're going to add some global way to always say a number is decimal,
> and I'm not sure I think that's a good idea even (I kind of think it
> might be better on a case by case basis to maybe tweak some prints so
> that for example "ls mmc 0:10" tells the user it's accessing partition
> 16 would lead to a quick "oh that's hex, #$%@!"), I think it should
> follow the radix notation, or if not, some other well known example.

Can you give examples for what you are thinking for radix notation?

BTW, quite a bit of the series is a clean-up, so can be reviewed separately.

Regards,
Simon