[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240112010630.GZ1674809@ZenIV>
Date: Fri, 12 Jan 2024 01:06:30 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: Guilherme Giácomo Simões <trintaeoitogc@...il.com>
Cc: linux-kernel@...r.kernel.org
Subject: Re: new library
On Thu, Jan 11, 2024 at 09:48:46PM -0300, Guilherme Giácomo Simões wrote:
> For ex: 1234 -> "12.34", and i show this in dmesg output: [09876] 12.34
Er... What's wrong with "%d.%0*d", n / 100, 2, n % 100 in sprintf/printk/etc.
arguments? It's slightly messier if you want to handle the negatives as well,
but also not impossible - "%s%d.%0*d", n < 0 ? "-" : "", abs(n) / 100, 2, abs(n) % 100
will do it, kernel and userland alike. And I'm pretty sure it's going to be cheaper
than your solution...
Powered by blists - more mailing lists