mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andreas Schwab <schwab@suse.de>
To: "Randy.Dunlap" <rddunlap@osdl.org>
Cc: Ray Lee <ray-lk@madrabbit.org>, <hps@intermeta.de>,
	Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] Re: sscanf("-1", "%d", &i) fails, returns 0
Date: Mon, 11 Nov 2002 21:08:41 +0100	[thread overview]
Message-ID: <je1y5rhnsm.fsf@sykes.suse.de> (raw)
In-Reply-To: <Pine.LNX.4.33L2.0211111019300.23954-100000@dragon.pdx.osdl.net> ("Randy.Dunlap"'s message of "Mon, 11 Nov 2002 11:09:28 -0800 (PST)")

"Randy.Dunlap" <rddunlap@osdl.org> writes:

|> Andreas Schwab wrote:
|> |> IOW, asking for an unsigned number (in the format string)
|> |> and getting "-123" does return 0.
|> 
|> | Not in C.  According to the standard scanf is supposed to convert the
|> | value to unsinged and return that.
|> OK, thanks, I found that in the C spec.
|> 
|> Now what does it mean to "convert the value to an unsigned and return
|> that."  This is the same as above, isn't it?
|> I.e., on the scanf() side, there is no conversion needed; just store the
|> value.

The C standard also supports ones-complement and sign-magnitude
representation of signed integers where signed<->unsigned conversion is a
non-trivial operation in the sense that the bit representation does
change.  And scanf knows the signedness of the destination due to the
format spec.

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 Nürnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

  reply	other threads:[~2002-11-11 20:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-11 14:54 Ray Lee
2002-11-11 19:09 ` Randy.Dunlap
2002-11-11 20:08   ` Andreas Schwab [this message]
2002-11-11 20:25   ` Ray Lee
2002-11-13  7:06     ` Randy.Dunlap
2002-11-14 17:34       ` Ray Lee
  -- strict thread matches above, loose matches on Subject: below --
2002-11-08 13:32 Douglas Gilbert
2002-11-08 19:22 ` [PATCH] " Randy.Dunlap
2002-11-08 19:41   ` Richard B. Johnson
2002-11-08 19:59     ` Randy.Dunlap
2002-11-08 20:19       ` Linus Torvalds
2002-11-08 22:09         ` Randy.Dunlap
2002-11-10 13:41           ` Henning P. Schmiedehausen
2002-11-11  3:05             ` Randy.Dunlap
2002-11-11  4:19               ` Randy.Dunlap
2002-11-11  9:27               ` Henning Schmiedehausen
2002-11-11 14:38               ` Andreas Schwab
2002-11-08 20:23       ` Richard B. Johnson

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=je1y5rhnsm.fsf@sykes.suse.de \
    --to=schwab@suse.de \
    --cc=hps@intermeta.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ray-lk@madrabbit.org \
    --cc=rddunlap@osdl.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®