#1028 comparing (un)signed char's

closed-fixed
5
2013-05-25
2005-11-28
Anonymous
No

#define MICROCONTROLLER_SAB80517

void main()
{ char a;

for(;;)
{
a +=1;

P5_7 = a < 0x80; // not working !!!!!

P5_6 = !(a > 0x80); // OK

P5_5 = a; // OK
}
}

whats about P5_7 = a < 0x80; ????

reinhard.fuchs@inode.at

sdcc vers. 2.4.8

thanks for any suggestion !!

Discussion

  • Maarten Brock

    Maarten Brock - 2005-11-28
    • assigned_to: nobody --> maartenbrock
    • milestone: --> 100455
    • status: open --> closed-rejected
     
  • Maarten Brock

    Maarten Brock - 2005-11-28

    Logged In: YES
    user_id=888171

    According to the C standard 0x80 is an unsigned int.
    According to the SDCC manual char is signed.
    I leave the math to you.

     
  • Bernhard Held

    Bernhard Held - 2005-11-28

    Logged In: YES
    user_id=203539

    > According to the C standard 0x80 is an unsigned int.
    > According to the SDCC manual char is signed.
    This can't be the whole story. The value range of variable
    'a' (signed char) is -128...+127, and this is always
    smaller than 0x80 == +128.
    Operations with both a 'signed char' and 'unsigned char'
    are really hairy, this needs a 2nd thought.

     
  • Bernhard Held

    Bernhard Held - 2005-11-28
    • assigned_to: maartenbrock --> bernhardheld
    • labels: 101550 --> C-Front End
    • milestone: 100455 -->
    • status: closed-rejected --> open
     
  • Bernhard Held

    Bernhard Held - 2005-11-29
    • milestone: --> fixed
    • summary: boolean castings ??? --> comparing (un)signed char's
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks