Bool type - can't it be zero / nonzero?

celopmuh humpolec at gmail.com
Sat Jun 7 03:50:03 PDT 2008


>From what I gathered, the inconsistency in using bool/int types is for the sake of optimization, and int logical values work faster mainly because they're 0 / non-0, not 0/1 (so that you can use simple subtraction to compare things).

But why is the bool type represented as 0 / 1 in the first place? We already know that zero/nonzero convention makes things faster, so why discard it?
The only thing it makes more complicated is comparing two bools, but I believe such comparison is not performed often and/or can be optimized better than comparison of two numbers.



More information about the Digitalmars-d mailing list