From: quanstro@quanstro.net (erik quanstrom)
Subject: [9fans] 8c puzzling behavior
Date: Tue, 8 Mar 2011 12:16:29 -0500 [thread overview]
Message-ID: <a32de54ece05e5c2bfee96835e370414@ladd.quanstro.net> (raw)
for this
uvlong u, i;
i = 31;
u = 0xff00000000000000ull;
i get
u & 1<<i -> 0xff00000000000000ull
u & 0x80000000 -> 0
u & (int)0x80000000 -> 0xff00000000000000ull
u & -2147483648 -> 0
to put a finer point on it,
(uvlong)(1<<i) -> 0xffffffff80000000
(uvlong)(0x80000000) -> 0x80000000
(uvlong)(int)0x80000000 -> 0xffffffff80000000
(uvlong)-2147483648 -> 0x80000000
so it seems clear that constants are treated as if unsigned, regardless,
but variables are not?
can this be correct? i hate to hazzard guesses about the c standard.
- erik
next reply other threads:[~2011-03-08 17:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-03-08 17:16 erik quanstrom [this message]
2011-03-08 20:21 ` geoff at plan9.bell-labs.com
2011-03-08 23:32 ` Bakul Shah
2011-03-08 23:54 ` erik quanstrom
2011-03-09 7:23 ` Charles Forsyth
2011-03-09 13:05 ` erik quanstrom
2011-03-08 17:21 erik quanstrom
2011-03-08 17:43 ` Lucio De Re
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=a32de54ece05e5c2bfee96835e370414@ladd.quanstro.net \
--to=quanstro@quanstro.net \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).