From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1624E2DB79B for ; Tue, 17 Feb 2026 12:01:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771329668; cv=none; b=lKSml9a5cTOwZcO7CsNww8DPrG8mFz7sRBLLyNc6il5ELGPVKh+X15mGuAE19oOWSxUuCiM/1ybU+JCT41ko0OaRyZdwNvEEbqqOYiJMiPafBYWXAUqfokRBgvZyIyWpSfzYW5rtE+V1TqO9mxXa/z4EkoRNz0Znv+hHezKfrE0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771329668; c=relaxed/simple; bh=rshydlMa1jENMICTfUWzlKLzdW3x7TqdWg/zLzqee7Q=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=t/bnNON6gEktUKx/YM4q5PBQNlJIq0j2P+PkMTgo+s2BIYBRMnhooG49yOec52nyuGkpP9fdTsf622GhV0SMJB6PP4LuNYv6pGu4vrQ4NgbmOU/as921+5FfZm9GT20Cs9LhkHdpFKka8H/bXbCh7/wvCltxbygfptOTd/fO4lQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Mt8SYuzB; arc=none smtp.client-ip=209.85.221.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Mt8SYuzB" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-4359249bbacso4100398f8f.0 for ; Tue, 17 Feb 2026 04:01:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1771329665; x=1771934465; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=PNV0W7jZ4pOxozo3alcAAE7nb1iK9x7imXxFCHNg6mA=; b=Mt8SYuzB9itfsYK0UqmIUr5E8eNyrWWHOrLohLL5sRmrsGY1U/LVPnZ1T2Tpy2h8rg iYDQ3B4onWEJYy0Baos3xPlqWx0VrOLOLSS7199t4kMiup62dVC1HSWLAMCb8+G9bdtc CEuoLUIZcODO2a8IVH7Nl6Ist/2SGFoV+1lVUzmql9iRhmYlpwmypFT1UFSHDcySVern VO/kxiAr7FulIu5C2Eirhtf8Er9wWMSNSE7mfp7QDxHjASrtWQ3UC3tt68HW7rxmzwG7 Wkjb+XVHjqquFpuuKXYPV71TM/topEK2Gt0qkPuJE1jnAxq86e9UgIFtqEebaWNygB0k +WFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1771329665; x=1771934465; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=PNV0W7jZ4pOxozo3alcAAE7nb1iK9x7imXxFCHNg6mA=; b=qxclmP4soPCDWlNC9sw7XTjV6n5pBDObSXbqvNnADav+MgnIpwNwa8lahfj3rhiKJq jxqiKOMu2KX84LEU6DqpoiTdkDYp/bVBG9wiSQpgjXAwNrwXNd6y222AgjDYkw/jwyuN ozUP0uMSarSqrbw068nz+vNndXDwahFYu847W2hiJq32t6PXzBhkHmRWN759ZMkxnVp8 ixfO/+rAcFpYlNzbkR+lgapbjzbDdApJTAVHxSJ+3K9KDbDuvPnBBaWPAW/xtOwE9z1t 37F2R9XUiADfDHsxa4Y2x/r3KGC6l2chO7SHgQOxwT58hxQwTJGDjbOHcV7mgxKAMFRI CocQ== X-Forwarded-Encrypted: i=1; AJvYcCXktzg/Z8n2pskaqR7TOSy+NuTnS451PXr8ZYZ8zSILnX3fuS1TmcJwOlmLixNKl/66PXK4vNIyBHM9udk=@vger.kernel.org X-Gm-Message-State: AOJu0YwDn5r+iw+iIr62MX2I6Wzjvj/1n/UOjxUusNd+9/PF315Xk7Rv xvXppw4O/RurCfTcZTFdU3A6jtj8X9KTtw0sLd9d0GOUQB/JmScfftR4 X-Gm-Gg: AZuq6aIvwaJ96hsF1SRtHpzzlAOip1iKCsaY3KNB2SIp0ySE0kSC/UIY4xCVYX0dcs0 Dv/o5Jv5Snyj4nqPGdkHP4azJPgcdPN0d/ayN1rA2gIHOS2GOCk4P5XHWZ98qVadaFKxLFnS33j xeg7whP4Wljv5oQ35+FR0IdET4ylro6ClwYFn2qQzYAsJJbWZGrjIS7cEWMEBUtMHUrjzKtUzM/ n7ADJHKYtsQZeZ/EGvuqYR889VF7vWatFLQBYY+QtbzUTKuS9qppLDMNGEhbfKCD7MbGZpuGeeX m8JMMOCn2GLhh0T4L5JvHTozHBbdBsCTMuySHwDcMf9kqCztHRZdn5Mz/YoXzWnWQXjATFrhUxs 0YBYp6PYC3MoibxNfVCZ69loMTBnfAnse0eXhvbP2Hqwd/33VxtRxFMvQ4qh8AizY6Ia6DWgFxo kHu7AiYVPCm+OTxkJJeBxjklDCFtuXYt37ulGPRopEMcSCqrBuZ8b6T7ykt8EwEo1A X-Received: by 2002:a05:6000:228a:b0:430:fd0e:a502 with SMTP id ffacd0b85a97d-4379d61a68amr18356332f8f.22.1771329665104; Tue, 17 Feb 2026 04:01:05 -0800 (PST) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43796a74918sm34371561f8f.17.2026.02.17.04.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Feb 2026 04:01:04 -0800 (PST) Date: Tue, 17 Feb 2026 12:01:03 +0000 From: David Laight To: Thomas =?UTF-8?B?V2Vpw59zY2h1aA==?= Cc: Willy Tarreau , linux-kernel@vger.kernel.org, Cheng Li Subject: Re: [PATCH v2 next] tools/nolibc: Optimise and common up the number to ascii functions Message-ID: <20260217120103.06145956@pumpkin> In-Reply-To: <20260216221620.449678f4@pumpkin> References: <20260208195308.4074-1-david.laight.linux@gmail.com> <20260213110859.5bff4705@pumpkin> <5e0ce1ac-a5a8-4a3b-ad11-97d2cf6076bc@t-8ch.de> <20260216221620.449678f4@pumpkin> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Mon, 16 Feb 2026 22:16:20 +0000 David Laight wrote: > On Mon, 16 Feb 2026 19:46:12 +0100 > Thomas Wei=C3=9Fschuh wrote: >=20 > > On 2026-02-13 11:08:59+0000, David Laight wrote: =20 > > > On Sun, 8 Feb 2026 19:53:08 +0000 > > > david.laight.linux@gmail.com wrote: > > > =20 > > > > From: David Laight > > > >=20 > > > > 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. =20 > > >=20 > > > Self-nak on this version :-( > > >=20 > > > The division code can end up generating a negative remainder for > > > very large values (probably only ones over 1<<63). =20 > >=20 > > Ok. Maybe some tests for these edgecases are in order, too. > > Do you want to add them? =20 >=20 > 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 >=3D base) { digit -=3D base; quotient++; } suffices (without s/if/while/). David