Say your two boolean values are workIsFinished
and customerIsInsane
, and the equivalent bit fields are doneWorking
and madUser
.
You can simply do something like:
doneWorking = workIsFinished ? 1 : 0;
madUser = customerIsInsane ? 1 : 0;
without having to worry about casting or any of that stuff. Any compiler worth its salt will be able to optimise that pretty thoroughly.