This is the mail archive of the
mailing list for the GCC project.
Re: Problem with cast from double to unsigned short int
- From: "John (Eljay) Love-Jensen" <eljay at adobe dot com>
- To: "Gederberg, Thomas K" <Thomas dot K dot Gederberg at boeing dot com>, GCC-help <gcc-help at gcc dot gnu dot org>
- Date: Wed, 14 Apr 2010 11:51:57 -0700
- Subject: Re: Problem with cast from double to unsigned short int
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
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
> Is this a bug with gcc?
No, I think it is a bug in the code.