Mail Archives: djgpp/2000/10/17/09:45:15
From: | "Murray Rogers" <mwr21 AT cam DOT ac DOT uk>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Re: Unsigned Int Problem
|
Date: | Tue, 17 Oct 2000 14:36:00 +0100
|
Organization: | University of Cambridge, England
|
Lines: | 32
|
Message-ID: | <8shkg5$75r$1@pegasus.csx.cam.ac.uk>
|
References: | <39EC53CC DOT EAA6B85E AT email DOT com>
|
NNTP-Posting-Host: | mwr21.quns.cam.ac.uk
|
X-Priority: | 3
|
X-MSMail-Priority: | Normal
|
X-Newsreader: | Microsoft Outlook Express 5.00.2314.1300
|
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2314.1300
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
Unsigned short int should do the job.
Derek Chew <sdchew AT email DOT com> wrote in message
news:39EC53CC DOT EAA6B85E AT email DOT com...
> Hi there everyone.. I just recently shifted from using Borland Turbo C++
> to DJGPP and I besides the funny error messages that GCC gives, its been
> quite a good experience...
>
> most recently, I noticed that one of my old functions that I wrote using
> TC has been acting wierdly.. I did some further investigate a bit futher
> and found that this line of code executes differently in TC and GCC
>
> main()
> {
> unsigned int data=1;
> data=0-data;
> printf("%u",data);
> return;
> }
>
> on TC, I will get the desire result of 65535 as the 16-bit unsigned int
> will overflow into and display this value... but apparently, under
> DJGPP/GCC, an unsigned int is 32-bit and I get the unwanted value of
> 4294967295 ...
>
> is there a good work around to allow the code to work in both compilers?
>
> thanks a lot guys!
>
- Raw text -