From: Richard Knutsson <ricknu-0@student.ltu.se>
To: kernel-janitors@vger.kernel.org
Subject: [KJ] [RFC] Regarding abs() and labs()
Date: Sat, 03 Feb 2007 01:13:44 +0000 [thread overview]
Message-ID: <45C3E1C8.2040105@student.ltu.se> (raw)
Hello all
Just took a look at abs() and can not understand why it seem so
overcomplicated. Why not just:
#define abs(x) ((x) < 0) ? -(x) : (x))
and skip labs() (not used anyway)
+ it gives a warning with -W if x is of a unsigned type ("condition is
always false" or similar).
But remember to use %u when printing an unsigned, took me a while before
I understood how an unsigned could contain a "negative" value :)
Happy weekend
Richard Knutsson
_______________________________________________
Kernel-janitors mailing list
Kernel-janitors@lists.osdl.org
https://lists.osdl.org/mailman/listinfo/kernel-janitors
next reply other threads:[~2007-02-03 1:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-02-03 1:13 Richard Knutsson [this message]
2007-02-03 1:44 ` [KJ] [RFC] Regarding abs() and labs() Randy Dunlap
2007-02-03 2:22 ` Richard Knutsson
2007-02-03 2:34 ` Randy Dunlap
2007-02-03 2:52 ` Richard Knutsson
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=45C3E1C8.2040105@student.ltu.se \
--to=ricknu-0@student.ltu.se \
--cc=kernel-janitors@vger.kernel.org \
/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.