×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Boolean expression in an equality

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 ?

RE: Boolean expression in an equality

V = R - x * W when x is greater than a AND there may be more to this equation than shown in your post?

RE: Boolean expression in an equality

It's a notation used in beam element solutions by integration, MacAuley's method from memory. It switches part of the integral on once a certain x is reached to apply local step changes in the SF diagram.

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

Wow, that never occurred to me, but now that I see it, could be very helpful.

RE: Boolean expression in an equality

In the early days of programming we used to use something like this in programs
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

Back in the "olden days" when memory was tight, and the number of characters of code that could be stored and loaded into a compiler was also a factor, efficiency of code tended to trump all other considerations of clarity etc, and tricks like this were very common.

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

(OP)
Jhardy1 - agreed .. I could also run a programming routine ..
- 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

not only obtuse, but a risk that a future software revision changes the default function behavior, causing the code to either crash or produce different results.

RE: Boolean expression in an equality

Agreed - it is pretty common for programming languages to use Logical TRUE = 1 and Logical FALSE = 0 (as Type INTEGER), enabling you to use this sort of shortcut. (Indeed, before the development of true Logical variable types, when Real and Integer variables were all that were available to the programmer, you would commonly define Integer constants TRUE = 1 and FALSE = 0 for exactly this purpose.)

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

In the early days, some programming languages would return 0 or -1 for false... hence the earlier noted construction.

-----*****-----
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

The expression:

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

When the first PCs came out, some programming languages (and different company versions) weren't that friendly, sometimes. That the reason for using the return of an actual boolean value. I have no idea of how the construct works with current languages.

-----*****-----
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

You could use an "if" function to use Boolean expressions without programming.
V(x):=if(x>a,R-W,R)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close