Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

** Community Tip** - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more!
X

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

Jul 27, 2022
11:35 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jul 27, 2022
11:35 AM

Inequality Help

Hello, sorry if this isn't the correct place to post but please help me out. I have the following eqn.

X:= a + b <= c + d = 0

How do I get X to be defined as the lesser of the two. I want it to be defined as C+D if it is smaller, Not 0 or 1.

It is only returning 0 or 1 depending on if the statement is true or false.

Solved! Go to Solution.

Labels:

1 ACCEPTED SOLUTION

Accepted Solutions

Jul 27, 2022
05:06 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jul 27, 2022
05:06 PM

Thanks for the response but a better solution I figured out is as follows:

X := if(a+b<=c+d,a+b,c+d) This allows the inequality to return the value instead of 1 or 0

5 REPLIES 5

Jul 27, 2022
01:17 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jul 27, 2022
01:17 PM

Then you probably want:

X:=min(a+b, c+d)

X will get the value of a+b if that is smaller than (or equal to) c+d.

Success!

Luc

Jul 27, 2022
05:06 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jul 27, 2022
05:06 PM

Thanks for the response but a better solution I figured out is as follows:

X := if(a+b<=c+d,a+b,c+d) This allows the inequality to return the value instead of 1 or 0

Jul 28, 2022
03:28 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jul 28, 2022
03:28 AM

Your IF statement is equivalent to the use of the min() function. The min() function is more compact.

Success!

Luc

Jul 28, 2022
08:14 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jul 28, 2022
08:14 AM

Sure its more compact but in other instances when I want to get the inequality to work, the min function will not. My question was not just in regards to the instance i posted, it was how to get an inequality function to return the value, not 1 or 0 for true or false. Thanks for the suggestion though, i will consider using min and max functions more in the future for simple inequality substitutes.

Jul 28, 2022
04:24 PM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Notify Moderator

Jul 28, 2022
04:24 PM

Your 'inequality function' is in fact what commonly known as a 'boolean expression'. That is an expression, it is a statement that should always result in either true (1) or false (0). You can use boolean expressions in programming constructs such as an IF or a WHILE to make decisions based upon the statement. And you can assign (the result of) a boolean expression to a variable and use that variable in the IF or WHILE.

Note that in your posting at the start of this thread, you assigned a boolean expression to the variable X:

X:= a + b <= c + d

X will get the result of the statement: "a+b is less than or equal to c+d". That statement is either true or false.

You could follow it up with:

X := IF(X, a+b,c+d)

Success!

Luc