Boolean expression in an equality
Boolean expression in an equality
(OP)
In dealing with a Shear / Moment Diagram .. came across this expression ..
V(x) := R - (x > a) * W
never seen a ">" or "<" operator in an equality expression like this ..
How does this work ? does it multiply W only if x > a ??
else V := R if a >= x ?
if (x > a) is true (=1) then V = R-W
else if (x <= a) is false (=0) then V = R
is this the principle how this works ?
V(x) := R - (x > a) * W
never seen a ">" or "<" operator in an equality expression like this ..
How does this work ? does it multiply W only if x > a ??
else V := R if a >= x ?
if (x > a) is true (=1) then V = R-W
else if (x <= a) is false (=0) then V = R
is this the principle how this works ?
RE: Boolean expression in an equality
RE: Boolean expression in an equality
TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! https://www.youtube.com/watch?v=BKorP55Aqvg
FAQ731-376: Eng-Tips.com Forum Policies forum1529: Translation Assistance for Engineers Entire Forum list http://www.eng-tips.com/forumlist.cfm
RE: Boolean expression in an equality
Cheers
Greg Locock
New here? Try reading these, they might help FAQ731-376: Eng-Tips.com Forum Policies http://eng-tips.com/market.cfm?
RE: Boolean expression in an equality
RE: Boolean expression in an equality
TRUE = (1 = 1) and
FALSE = NOT TRUE
because languages often used 0 or -1 for False...
-----*****-----
So strange to see the singularity approaching while the entire planet is rapidly turning into a hellscape. -John Coates
-Dik
RE: Boolean expression in an equality
TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! https://www.youtube.com/watch?v=BKorP55Aqvg
FAQ731-376: Eng-Tips.com Forum Policies forum1529: Translation Assistance for Engineers Entire Forum list http://www.eng-tips.com/forumlist.cfm
RE: Boolean expression in an equality
However, having had to deal with debugging my own software "kludges", and those of my colleagues, if I am coding anything today, I am very liberal with my comments, I use meaningful variable names, and I will use "structured programming" blocks rather than "in-line" workarounds.
E.g.:
V(x) := R - (x > a) * W
gets the job done, but:
IF (x > PointLoadOffset)
THEN
Shear(x) := EndReaction - PointLoad
ELSE
Shear(x) := EndReaction
END IF
is far more comprehensible, and easier to debug.
http://julianh72.blogspot.com
RE: Boolean expression in an equality
- but this use of Boolean expressions inside a typical equality statement is quite the "new thing" ..
- been around MathCad & programming for a long time .. never seen this combination before.
makes for a tidy & clean expression.
RE: Boolean expression in an equality
but obtuse, nevertheless, since you, and presumably others, didn't exactly know what the intent was.
TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! https://www.youtube.com/watch?v=BKorP55Aqvg
FAQ731-376: Eng-Tips.com Forum Policies forum1529: Translation Assistance for Engineers Entire Forum list http://www.eng-tips.com/forumlist.cfm
RE: Boolean expression in an equality
RE: Boolean expression in an equality
However, a "strong" structured programming language would throw an error when you mix Logical variables (or expressions) with Real and Integer variables in one expression.
http://julianh72.blogspot.com
RE: Boolean expression in an equality
-----*****-----
So strange to see the singularity approaching while the entire planet is rapidly turning into a hellscape. -John Coates
-Dik
RE: Boolean expression in an equality
R - (x > a) * W
would yield different results if FALSE is assigned a value of -1 rather than 0.
For zero (the most common value in my experience), the expression yields a value of R. For -1, the resulting value is R + W. Using Integer equivalent values for Logical expressions in a Real or Integer expression is ambiguous (and hazardous) if you're not sure of the Integer value which is assigned to FALSE.
http://julianh72.blogspot.com
RE: Boolean expression in an equality
-----*****-----
So strange to see the singularity approaching while the entire planet is rapidly turning into a hellscape. -John Coates
-Dik
RE: Boolean expression in an equality
TTFN (ta ta for now)
I can do absolutely anything. I'm an expert! https://www.youtube.com/watch?v=BKorP55Aqvg
FAQ731-376: Eng-Tips.com Forum Policies forum1529: Translation Assistance for Engineers Entire Forum list http://www.eng-tips.com/forumlist.cfm
RE: Boolean expression in an equality
V(x):=if(x>a,R-W,R)