We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
TbooleanVALUE showNUMBER ( int number ) { switch (number) { case 0: printf("0"); break; case 1: printf("1"); break; case 2: printf("2"); break; case 3: printf("3"); break; case 4: printf("4"); break; case 5: printf("5"); break; case 6: printf("7"); break; case 7: printf("8"); break; case 8: printf("9"); break; case 9: printf("9"); break; } if ( number > 5 ) return FALSE ; if ( number < 2 ) return TRUE; return 2; }
Yes, a float can store lots of numbers.
But why you you give it a name Boolean, when your intention isn't to use it as a boolean? 2 isn't a boolean value.
Some boolean logic.
a := true; b := false; a != b; a == !b b == !a a == !!a b == !!b
But what happens with your value 2? What is !2? Is it true? Is it false? What is !!2? Is it back to 2? Or undefined? Or what? Will !!2 be same as 2?
When you have a data type with the name boolean, that is a promise to the reader that the data type is intended for a boolean state - not suddenly some random numeric value.
Another thing - why #define when the language have a specific keyword to define a data type?