Forgot username/password? Don't have an account?
Login with Facebook
Home » Courses » Smooth Operator » From Rational to Boolean

From Rational to Boolean

All the operators we worked with so far returned in our trace panel a value of true or false. In this video we'll see that connection of our operators results in the Boolean data type as we explore storing our operator values into Boolean variables for reference.

We know how Boolean variables work with equality operators. Now we'll see how rational operators can be used in Boolean form. For example let's declare a few variables using var and assign values to them. Let the values be: a=5, b=10, c=b. Now we can compare these variables with one another and assign this comparison to another variable of type Boolean. Here's an example to understand this:

var isTrue: Boolean = (c<=a);

Here c<=a is what we want to find and we can find it directly. But if we want to change from rational to Boolean, we can use the above declaration.

So now the new Boolean variable is isTrue and we'll now work with this variable wherever we need to compare c<=a. The answer is still either true or false, depending upon the values: here the answer would be false as it does not satisfy the values of a and c. The advantage of changing from rational to Boolean is that we need not write the equality every time when we want to compare. We can just write trace(isTrue) to check whether the equation is satisfied or not. Here the equation is small and you may not find any difficulty, but when we deal with big equations, then this is definitely one of the best options to be considered.

Got A Question?

'I love being Prime'

Have a question but don't want to ask it publicly? If you are a prime member just ask right here and we will get back to you within 48 hours. Not prime yet? no worries you can ask publicly below.

Act now while we have available seating

Our on line school is private, affordable and interactive with trainer support.
Act now save your seat before someone else takes yours.
Act now