Machine Code with Boolean

closed account (N36fSL3A)
Just a quick question. Since a bool type variable is equal to True/False, or off and on, is it possible to code a program (Such as an adder/half adder) with these values alone?
As long as you don't do any I/O or need any indirection... then yes - although it would be criminally ineffecient.
Last edited on
closed account (N36fSL3A)
I know but just as a brain workout. I'm actually doing it like this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
int addition(int num1, int num2)
{
    // First convert to binary values

    // Now use both my half adders
}

int main()
{
    int input1, input2;

    std::cout << "Welcome to Fred's Binary adder\n"

    // Get input
    
    int answer = addition(input1, input2);

    cout << Answer;

}


So input wouldn't be a problem
Topic archived. No new replies allowed.