Answer the question
In order to leave comments, you need to log in
How is unary minus and logical negation implemented?
You need to make a variable with three values: one neutral and two opposite, which can be inverted.
Thought up while such variants:
Values {-1,0,1} and operation of an inversion by a unary minus x=-x.
Values {0,1,2} and xor invert operation x=x^255.
In which case will the inversion be faster?
You also need to make a related variable, but the neutral value is no longer needed, two opposite values \u200b\u200bthat can be inverted are enough. Should I make a bool type or can I take one of the above structures? What is the machine implementation of the negation operation for a bool variable? Does it have any advantages over the above methods?
Answer the question
In order to leave comments, you need to log in
enum Type3Values {t3One, t3Two, t3Three};
class Type3 {
protected:
Type3Values value;
public:
Type3();
//Ваши операции
Type3Values oper1(Type3Values v);
Type3Values oper2(Type3Values v);
Type3Values oper3(Type3Values v);
//Операции для bool
... oper1(bool v);
... oper2(bool v);
... oper3(bool v);
};
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question