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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

Question on Mathcad while loops

aharkness
1-Visitor

Question on Mathcad while loops

When I have a while loop that goes as long as x does not equal 1.0, then it does the operation x = x + .1. The result is an infinite while loop. Why does this happen

3 REPLIES 3

Never test for exact equality using reals!  Always do a comparison along the lines of  |x - 1|<10^-6 .

xvals.PNG

Alan 

Werner_E
25-Diamond I
(To:aharkness)

Its better to have a worksheet to see what you actually did.

Maybe you ran into a accuracy problem. Not sure though.

Maybe not :  "while x does not equal 1"

but rather:   " while x is less than 1"

Announcements

Top Tags