public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: Simon Glass <sjg@chromium.org>
Cc: "U-Boot Mailing List" <u-boot@lists.denx.de>,
	"Eugeniu Rosca" <erosca@de.adit-jv.com>,
	"Roland Gaudig" <roland.gaudig@weidmueller.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Stefan Herbrechtsmeier" <stefan.herbrechtsmeier@weidmueller.com>,
	"Sean Anderson" <seanga2@gmail.com>,
	"Marek Behún" <marek.behun@nic.cz>, "Marek Vasut" <marex@denx.de>,
	"Joe Hershberger" <joe.hershberger@ni.com>
Subject: Re: [PATCH 00/15] lib: Add support for a decimal 0m prefix for numbers
Date: Tue, 20 Jul 2021 15:28:32 -0400	[thread overview]
Message-ID: <20210720192832.GO9379@bill-the-cat> (raw)
In-Reply-To: <CAPnjgZ0wtB4fo082KoGSvPy5bw3S_k7z512hS5SUrCaSQxXsBQ@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3010 bytes --]

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@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@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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 659 bytes --]

  reply	other threads:[~2021-07-20 19:28 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-20 13:29 [PATCH 00/15] lib: Add support for a decimal 0m prefix for numbers Simon Glass
2021-07-20 13:29 ` [PATCH 01/15] hash: Ensure verification hex pairs are terminated Simon Glass
2021-07-20 13:29 ` [PATCH 02/15] global: Convert simple_strtoul() with hex to hextoul() Simon Glass
2021-07-20 13:29 ` [PATCH 03/15] global: Convert simple_strtoul() with decimal to dectoul() Simon Glass
2021-07-20 13:29 ` [PATCH 04/15] lib: Comment the base parameter with simple_strtoul/l() Simon Glass
2021-07-20 13:29 ` [PATCH 05/15] lib: Drop unnecessary check for hex digit Simon Glass
2021-07-20 13:29 ` [PATCH 06/15] lib: Add tests for simple_strtoull() Simon Glass
2021-07-20 13:29 ` [PATCH 07/15] lib: Add octal tests for simple_strtoul/l() Simon Glass
2021-07-20 13:29 ` [PATCH 08/15] lib: Move common digit-parsing code into a function Simon Glass
2021-07-20 13:29 ` [PATCH 09/15] doc: Convert command-line info to rST Simon Glass
2021-07-20 13:29 ` [PATCH 10/15] doc: Add a note about number representation Simon Glass
2021-07-20 13:29 ` [PATCH 11/15] lib: Allow using 0x when a decimal value is requested Simon Glass
2021-07-20 13:29 ` [PATCH 12/15] lib: Support a decimal prefix 0m Simon Glass
2021-07-20 13:29 ` [PATCH 13/15] RFC: lib: Support a binary prefix 0y Simon Glass
2021-07-21  8:05   ` Sean Anderson
2021-07-21  8:30     ` Wolfgang Denk
2021-07-21  8:27   ` Wolfgang Denk
2021-07-21 14:23     ` Simon Glass
2021-07-22  9:48       ` Wolfgang Denk
2021-07-22 13:28         ` Simon Glass
2021-07-22 14:44           ` Tom Rini
2021-07-23  3:07             ` Simon Glass
2021-07-23  6:55           ` Wolfgang Denk
2021-07-23 21:41             ` Simon Glass
2021-07-24 13:00               ` Wolfgang Denk
2021-07-20 13:29 ` [PATCH 14/15] RFC: lib: Use 0o prefix for octal Simon Glass
2021-07-20 13:29 ` [PATCH 15/15] RFC: Change simple_strtoul() et al to default to hex Simon Glass
2021-07-20 14:22 ` [PATCH 00/15] lib: Add support for a decimal 0m prefix for numbers Tom Rini
2021-07-20 15:57   ` Simon Glass
2021-07-20 16:05     ` Tom Rini
2021-07-20 16:30       ` Eugeniu Rosca
2021-07-20 18:33       ` Simon Glass
2021-07-20 19:28         ` Tom Rini [this message]
2021-07-21 13:57           ` Simon Glass
2021-07-21  7:52       ` Wolfgang Denk
2021-07-21 14:46         ` Simon Glass
2021-07-23 21:41           ` Simon Glass
2021-07-20 15:00 ` Jonathan A. Kollasch
2021-07-20 15:04   ` Tom Rini
2021-07-21  7:42 ` Wolfgang Denk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210720192832.GO9379@bill-the-cat \
    --to=trini@konsulko.com \
    --cc=erosca@de.adit-jv.com \
    --cc=joe.hershberger@ni.com \
    --cc=marek.behun@nic.cz \
    --cc=marex@denx.de \
    --cc=roland.gaudig@weidmueller.com \
    --cc=seanga2@gmail.com \
    --cc=sjg@chromium.org \
    --cc=stefan.herbrechtsmeier@weidmueller.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox