All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: "Thomas Weißschuh" <linux@weissschuh.net>
Cc: Willy Tarreau <w@1wt.eu>,
	linux-kernel@vger.kernel.org, Cheng Li <lechain@gmail.com>
Subject: Re: [PATCH v2 next] tools/nolibc: Optimise and common up the number to ascii functions
Date: Tue, 17 Feb 2026 12:01:03 +0000	[thread overview]
Message-ID: <20260217120103.06145956@pumpkin> (raw)
In-Reply-To: <20260216221620.449678f4@pumpkin>

On Mon, 16 Feb 2026 22:16:20 +0000
David Laight <david.laight.linux@gmail.com> wrote:

> On Mon, 16 Feb 2026 19:46:12 +0100
> Thomas Weißschuh <linux@weissschuh.net> wrote:
> 
> > On 2026-02-13 11:08:59+0000, David Laight wrote:  
> > > On Sun,  8 Feb 2026 19:53:08 +0000
> > > david.laight.linux@gmail.com wrote:
> > >     
> > > > From: David Laight <david.laight.linux@gmail.com>
> > > > 
> > > > Implement u[64]to[ah]_r() using a common function that uses multiply
> > > > by reciprocal to generate the least significant digit first and then
> > > > reverses the string.    
> > > 
> > > Self-nak on this version :-(
> > > 
> > > The division code can end up generating a negative remainder for
> > > very large values (probably only ones over 1<<63).    
> > 
> > Ok. Maybe some tests for these edgecases are in order, too.
> > Do you want to add them?  
> 
> The problem is I'm not sure how to decide where they are.
> The v1 patch is fine, it expects to get a large remainder and then
> fixes up the error.

I think I can convince myself that the error on the quotient is less
than 2 (and some of that 2 is the remainder that becomes the digit).
Which means the maximum remainder (for base 10) is less than 20.
So a simple:
	if (digit >= base) {
		digit -= base;
		quotient++;
	}
suffices (without s/if/while/).

	David

      reply	other threads:[~2026-02-17 12:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-08 19:53 [PATCH v2 next] tools/nolibc: Optimise and common up the number to ascii functions david.laight.linux
2026-02-13 11:08 ` David Laight
2026-02-16 18:46   ` Thomas Weißschuh
2026-02-16 22:16     ` David Laight
2026-02-17 12:01       ` David Laight [this message]

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=20260217120103.06145956@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=lechain@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@weissschuh.net \
    --cc=w@1wt.eu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.