From: Al Viro <viro@zeniv.linux.org.uk>
To: "Guilherme Giácomo Simões" <trintaeoitogc@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: new library
Date: Fri, 12 Jan 2024 01:06:30 +0000 [thread overview]
Message-ID: <20240112010630.GZ1674809@ZenIV> (raw)
In-Reply-To: <5AFF5BF9-BD11-4A60-BD42-7EC516164D41@gmail.com>
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...
prev parent reply other threads:[~2024-01-12 1:06 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-12 0:48 new library Guilherme Giácomo Simões
2024-01-12 1:06 ` Al Viro [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=20240112010630.GZ1674809@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=trintaeoitogc@gmail.com \
/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.