[PATCH 00/15] lib: Add support for a decimal 0m prefix for numbers
Tom Rini
trini at konsulko.com
Tue Jul 20 21:28:32 CEST 2021
On Tue, Jul 20, 2021 at 12:33:14PM -0600, Simon Glass wrote:
> Hi Tom.
>
> On Tue, 20 Jul 2021 at 10:05, Tom Rini <trini at konsulko.com> wrote:
> >
> > On Tue, Jul 20, 2021 at 09:57:55AM -0600, Simon Glass wrote:
> > > Hi Tom,
> > >
> > > On Tue, 20 Jul 2021 at 08:22, Tom Rini <trini at 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.
> >
> > (123)10 would be "123" in decimal. Which is indeed a mouthful. But it
> > would also be generic and (123)16 would be 0x123. So the parsing
> > shouldn't be too hard, for most commands. But then yes, expressions
> > become quite hard.
> >
> > > > 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?
> >
> > Well, since we don't have subscript in shell, '(number)base' would how
> > it would be. Which I'm not convinced is better than making it clear to
> > users that almost everything is hex input, including a few places that
> > might surprise you such as partition numbers.
>
> After a bit of thought and digging, I think that is a mathematical
> thing and confusing/unworkable on the command line.
I agree.
> Should we consider 0t for decimal?
My biggest concern is that when I search for "0t prefix" the first
relevant answers are the MS links where 0t is for ocTal, and not the
other examples where it's decimal (base Ten, I assume).
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210720/02265dad/attachment.sig>
More information about the U-Boot
mailing list