GENERAL: IMPLEMENTATION OF 'BIT' TYPE CASTS
Information in this article applies to:
The Keil C Compiler support the data type bit. However, the compiler manual lacks information on the way type casts are implemented with this data type.
You are correct, the Manual does not contain this information.
When a integer or float type is casted to a bit, the value is compared with 0. If the value is not '0', the bit is set to '1'. The operation is identical with the behavior in compare statements.
unsigned char uc; bit b; b = uc; /* is identical to: */ if (uc) b = 1; else b = 0;
A bit cast to a scalar type sets the value to 0 when the bit is clear; 1 when the bit is set.
Last Reviewed: Monday, May 3, 2004
of your data.