Keil Logo


Information in this article applies to:

  • C51 All Versions
  • C166 All Versions
  • C251 All Versions


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

Did this article provide the answer you needed?
Not Sure
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.