Renesas Technology, Tools FAQs
Last Updated: December 20, 2000
Document Number: 01051240_e
Q.
When executing the following program, long-type variable "l" is supposed to hold "-1". However, the results become 0xF(15). How
can I make the results be "-1"?
void main( void )
{
struct
{
short r : 10 ;
short i : 4 ;
short s : 2 ;
} buf ;
long l ;
buf.i = -1 ;
l = (long)buf.i ;
}
A.
NC30WA processes the bit field member type as 'unsigned'. Therefore, when a long type variable is stored (transferred), the value is
'zero-expanded'. To have this treated as 'signed', make sure you explicitly declare it as 'signed' in the bit field member type
declaration.
[Example]
struct
{
signed short r : 10 ;
signed short i : 4 ;
signed short s : 2 ;
} buf ;
Top of Page | Back to Previous Page
Terms of Use Privacy Policy
(C)2004 Renesas Technology Corp., All Rights Reserved.
Comentarios a estos manuales