cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

What am I doing wrong with if statement

mcbedfor1
5-Regular Member

What am I doing wrong with if statement

Hello All,

 

I am using Mathcad Prime 4.0. As seen in the photo below, I am just trying to use a simple if statement. I am wondering what I am doing wrong? The answer I should be receiving in my check is "OK" . Any suggestions?

1.PNG

 

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:mcbedfor1)

Your running into an accuracy issue. Bear in mind that:

- all united values are ALWAYS internally converted into SI units.

- there is ALWAYS a finite accuracy when dealing with numerics.

Here goes:

LM_20171114_Accuracy.png

So the difference between x-y and z is just above 0.

 

When comparing numerical data, allow for some tolerance.

Success!
Luc

View solution in original post

4 REPLIES 4
LucMeekes
23-Emerald III
(To:mcbedfor1)

Your running into an accuracy issue. Bear in mind that:

- all united values are ALWAYS internally converted into SI units.

- there is ALWAYS a finite accuracy when dealing with numerics.

Here goes:

LM_20171114_Accuracy.png

So the difference between x-y and z is just above 0.

 

When comparing numerical data, allow for some tolerance.

Success!
Luc

mcbedfor1
5-Regular Member
(To:LucMeekes)

Makes sense, thank you for your help!

When comparing numerical data, allow for some tolerance.


One method to acheive this is to use Mathcad's "approximate equality" option:

Capture.PNG

mcbedfor1
5-Regular Member
(To:MJG)

That will work great in my situation. Thanks!

Top Tags