This content has been marked as final.
Show 9 replies

1. Re: Help with Boolean
3004 Nov 19, 2009 9:38 AM (in response to 801456)To check if both X and Y are true, use
Edited by: jverd on Nov 19, 2009 7:38 AMif (X && Y)

2. Re: Help with Boolean
843789 Nov 19, 2009 9:36 AM (in response to 801456)boolean okay(int a,int b,int c) { return 0<a && 0<b && 0<c && a<(b+c) && c<(a+b) && b<(a+c); }


4. Re: Help with Boolean
843789 Nov 19, 2009 9:37 AM (in response to 801456)alaaraulo wrote:
Use the AND operator:
and i suggested to write expressions like that to be compared , (a + b > c) , (a + c > b) , (b + c > a) how to write a boolea expression , and if the first expression true so the second one is false and the third one should be what ?
Each of your comparisons will be a boolean subexpression that will occupy condition1, 2 or 3.if ( (condition1) && (condition2) && (condition3) ) { //... }

5. Re: Help with Boolean
843789 Nov 19, 2009 9:39 AM (in response to 3004)jverd wrote:
So this is a valid triangle: (a=2,b=4,c=10000000)?alaaraulo wrote:
If any one of them is true, you don't care about the other ones.
and if the first expression true so the second one is false and the third one should be what ?
After all, a is less than 10000004! 
6. Re: Help with Boolean
3004 Nov 19, 2009 9:40 AM (in response to 843789)endasil wrote:
Yeah, sorry, not awake yet. I edited that reply out of existence, but not quickly enough.jverd wrote:
So this is a valid triangle: (a=2,b=4,c=10000000)?alaaraulo wrote:
If any one of them is true, you don't care about the other ones.
and if the first expression true so the second one is false and the third one should be what ?
After all, a is less than 10000004!
:) 
7. Re: Help with Boolean
843789 Nov 19, 2009 9:41 AM (in response to 3004)jverd wrote:
Way to sneak the correct reply back into position 1 though :P
Yeah, sorry, not awake yet. I edited that reply out of existence, but not quickly enough.
:) 

9. Re: Help with Boolean
843789 Nov 20, 2009 8:19 AM (in response to 843789)If 0<a,b,c, at least one can be bigger than the sum of the others: the biggest one.
So we can check the signum of (a+bc).(a+cb).(a+b+c) or
signum (a+bc).signum (a+cb).signum (a+b+c)
Their being positive is equivalent to a,b,c are possible sides for a triangle.
Indeed, Heron's formula for the area of the triangle is
Area=SQRT(s(sa)(sb)(sc)),
where s=(a+b+c)/2 or perimeter/2.
http://mste.illinois.edu/dildine/heron/triarea.html