Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

[Programming] Condition problem

Status
Not open for further replies.

rrozz

Chemical
Jul 2, 2011
9
Hi again,

The enclosed program selects the most appropriate pipe stub from a standard. Although the program works, it returns bad results.

For specified dimensions of pipe, it doesnt find the anticipated result and iterates till it runs out of arguments.

The condition d.2oprz+2*?.2oprz=(boolean eq.)=d.zkró?ca[k*mm for specified dimensions should be fulfilled at 11th iteration, but the loop does not exits.

Can any one help?
 
Replies continue below

Recommended for you

I don't know how much math or programming you took in school, but surely, you realize that computers do not store decimal values exactly?


Any decimal value you enter is stored as a binary floating point number per IEEE standard. Therefore, unless you are using only integers, it would be exceeding unlikely to get an exact match for two seemingly identical decimal values. If you do the actual math, you'll see that the values differ by 2.776E-17 mm.

Read "Lookup Functions" in the help files for how Mathcad does it for its internal lookup functions. You need to determine a tolerance and program accordingly.

TTFN

FAQ731-376
Chinese prisoner wins Nobel Peace Prize
 
Thanks for your feedback.
Your sarcasm is unnecessary, even if my knowleadge is bad.
 
rrozz, your comment about sarcasm is no way to say thank you very much for someone's help. Gee, you ask a technical question on a forum and 3.5 hours later you get a relevant answer. The answer was prefaced with a statement that pretty much explained that he thought you already knew, but just in case, he went ahead to explain a possible cause anyways. Not everyone gets/deserves a trophy for participation.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor