Skip to main content
DCtech
Associate III
October 13, 2020
Question

Keeping Signed and Unsigned Variables or Values

  • October 13, 2020
  • 1 reply
  • 699 views

I wonder about the keeping signed and unsigned values in proccessor.

For example I have this define

#define MY_NUMBER 8

How to decide MCU number of "8" signed or "unsigned" value.

How to convert binary number to keeping.

For example I am doing static analysis this define give an message give a signed or unsigned indicator. Sometimes I have to use like that #Define​ MY_NUMBER 8U

    This topic has been closed for replies.

    1 reply

    TDK
    Super User
    October 13, 2020

    > How to decide MCU number of "8" signed or "unsigned" value.

    A bare number "8" in C code will become a signed int. To make it unsigned, add the U suffix. This is not something you can configure elsewhere. Note that a #define isn't a variable, it's just used by the preprocessor. The signed/unsigned errors will happen where/how you use it.

    > How to convert binary number to keeping.

    I'm not sure what you're asking here. You can write a binary literal using a 0b prefix. So 0b1111011 would evaluate to 123.

    "If you feel a post has answered your question, please click ""Accept as Solution""."