cancel
Showing results for 
Search instead for 
Did you mean: 

Keeping Signed and Unsigned Variables or Values

DCtech
Associate II

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

1 REPLY 1
TDK
Guru

> 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".