ARM Technical Support Knowledge Articles


Applies to: General Topics


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.

Article last edited on: 2004-05-03 20:14:34

Rate this article

Disagree? Move your mouse over the bar and click

Did you find this article helpful? Yes No

How can we improve this article?

Link to this article
Copyright © 2011 ARM Limited. All rights reserved. External (Open), Non-Confidential