elcyron

hi there,

i'm new to programming so this is probably pretty easy to solve but i just cant do it...

the idea is to save several booleans in a single integer.

image a sqare, 4 corners - each one might be rounded. i DONT want to declear an bool for every corner and set it to TRUE for rounded or FALSE for not rounded.

what i want is to assign values to each corner and add them to get a unique value for each possible combination of rounded and unrounded corners.

values for the corners would be 1, 2, 4, 8.

so a resulting value of 6 would have second and third corner rounded.

this IS pretty easy, after all i figured this out by my self. but how the hell can i implement that ?

one way might be to convert the value to binary and compare the digits.

another one could be a huge if-statement that decraeses until value=0.

i guess there is a real easy way i just can't come up with. probably something containing an ANDstatement.

can anyone give me a hint?

i'm new to programming so this is probably pretty easy to solve but i just cant do it...

the idea is to save several booleans in a single integer.

image a sqare, 4 corners - each one might be rounded. i DONT want to declear an bool for every corner and set it to TRUE for rounded or FALSE for not rounded.

what i want is to assign values to each corner and add them to get a unique value for each possible combination of rounded and unrounded corners.

values for the corners would be 1, 2, 4, 8.

so a resulting value of 6 would have second and third corner rounded.

this IS pretty easy, after all i figured this out by my self. but how the hell can i implement that ?

one way might be to convert the value to binary and compare the digits.

another one could be a huge if-statement that decraeses until value=0.

i guess there is a real easy way i just can't come up with. probably something containing an ANDstatement.

can anyone give me a hint?