in Embedded Wizard Studio by

How would I do the following in Chora?

uint8 x;

 x  &=  ~(1 << 0);

x = x & ~(1 << 0); doesn't seem to work either.

1 Answer

0 votes

Hello Mike,

thank you very much for this report. You have encountered an error in Chora compiler. The ~ operator seems to accept 32-bit signed/unsigned operands only. The constant number 1, however, is considered as int8 value. The Chora compiler reports thereupon an error message. We will fix the error in the next version.

Trying to cast the value explicitly to int32 does not work because of optimization the constant value is re-evaluated resulting again in int8. Following are the few possible workarounds to achieve your desired results:

Option 1:

var uint8 x    = ...;
var int32 val1 = 1;

x = uint8( x & ~( val1 << 0 ));

Option 2:

var uint8 x = ...;

x = uint8( x & (( 1 << 0 ) ^ 0xFFFFFFFF ));

I hope the workarounds help you further.

Best regards

Paul Banach

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint