RE: Problem with cast from double to unsigned short int

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Yes, short int is 16-bit.  Also, yes it does produce correct results for 0..32767.  Thanks.

-----Original Message-----
From: John (Eljay) Love-Jensen [mailto:eljay@xxxxxxxxx] 
Sent: Wednesday, April 14, 2010 1:52 PM
To: Gederberg, Thomas K; GCC-help
Subject: Re: Problem with cast from double to unsigned short int

Hi Thomas,

I presume that short on your platform is 16-bit.

Also, I presume that this line...

is = (short int) ((double)(ius));

...yields correct results when ius is 0 through 32767.

Is that correct?

I think that when "ius > 32767" on such a platform, the result is undefined
behavior.

If I am correct:  as such, -32768 is a reasonable value.  So is -13000.

But I may be mistaken, and hopefully someone can site ISO 14882
chapter/verse.

> Is this a bug with gcc?

No, I think it is a bug in the code.

Sincerely,
--Eljay



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux