🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #6283

ANSI scanf dropping sign bit?

#6283
From: martin
Date: Wed, 07 Mar 1990 16:02
34 lines
1254 bytes
Why does the following program when linked to an ANSI standard library
produce the following:

input: 90000000

output: 10000000

input: 80000000

output: 00000000

#include <stdio.h>

int main()
{
	unsigned int	input;

	scanf("%x", &input);

	printf("%x\n", input);
}

It appears that sign bit is being dropped.  I have run this program on
Sys V.3.2 and it retains the sign bit, but this is not ANSI compliant.

Any hints...
thanks

                          
                  _/_          |
 ______  __.  __  /  o ____    |  textronix!reed!intelhf!clubmed!martin
/ / / <_(_/|_/ (_<__<_/ / <    |
                               |  martin@clubmed.hf.intel.com
                               |
Technical Details
Message-ID: <491@dios.hf.intel.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think!mintaka!ogicse!intelhf!dios!clubmed.hf.intel.com!martin

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think!mintaka!ogicse!intelhf!dios!clubmed.hf.intel.com!martin
From: martin@clubmed.hf.intel.com.ogi.edu
Newsgroups: comp.std.c,comp.lang.c
Subject: ANSI scanf dropping sign bit?
Keywords: ANSI
Message-ID: <491@dios.hf.intel.com>
Date: 7 Mar 90 16:02:12 GMT
Sender: martin@dios.hf.intel.com
Reply-To: martin@clubmed.hf.intel.com (Martin Wilde)
Organization: OMSO Software Engineering - Intel Corp. - Hillsboro Or.
Lines: 34