How can I make a if simplier with hex

Helloo All,

I have this code

if (itemp==0)
{ 
  byte payloadTemperature[] = {0x2C};
}
else
{ 
    byte payloadTemperature[] =  {0x32};
}

I would like to make it simplier looking at this

byte payloadTemperature[] = (itemp==0) ? {0x2C} : {0x32};

but I can not compile. I wundering if my two

{0x2C} : {0x32}

are well writen.

Can I have all in one line?

Thank

byte payloadTemperature[] =  {0x32};

The above syntax is used to declare and initialize a one element array, which is completely pointless.

Just use this:

byte payloadTemperature =  0x32;

Is there some particular reason to use hex notation instead of decimal (0x32 = 50)?

There is no point in defining and initialising an array that immediately goes out of scope

pierrot10: I would like to make it simplier looking at this

Why?

To my mind your first version is much easier to understand.

And it won't make any difference to the compiler which version you use.

...R