Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
I could not solve a simple problem (the radius of the ball) by the method of scientific poking (see please Trial and error).
I decided that one bug got into my head. But I decided not to give up and converted the file into Mathcad Prime 4 (see please attachs). The bug was not in my head, but in Mathcad 15. What is this bug?
Solved! Go to Solution.
While I agree with the better programming style suggested by Werner, the behaviour in Mathcad 11 is similar to that in Prime:
My guess its due to the (fortunate) lack of Static Unit Checking.
Success!
Luc
I won't call it a bug as "return" is not a legit way to end a loop ("break" is the command you'll have to use for it).
or
EDIT: Thinking about it again it seems that an additional cause for your attempt failing is because of the unit you use (here is one of the few point where Prime has an advantage).
You can make it work using one of the unit tricks you like so much and use so often:
Nonetheless I think that its better programming style to use "break" and not "return" to cancel a loop and also it would be better just for clearness to use r.1 for the random radius rather than r, which is also the name of the program.
While I agree with the better programming style suggested by Werner, the behaviour in Mathcad 11 is similar to that in Prime:
My guess its due to the (fortunate) lack of Static Unit Checking.
Success!
Luc
My guess its due to the (fortunate) lack of Static Unit Checking.
Yes, its sure a problem with the unit used and SUC seems to be first choice in the search for a culprit.
I just wonder why the break/return combination works OK then. It may not be a bug, but sure an inconsistent behavior. And the error message does not indicate that it could be a unit problem.
Needless to say that your sheet fails in MC15, too.
EDIT: I think I got it!
Mathcad does not realize/check that the while loop is never left other then by breaking out with return. So there may be the case that the loop is terminated in a regular way and then we need a return result with compatible units compared to the return statement in the loop. A simple 0 at the end does the job as in MC15 0 is compatible with any unit (on contrary to Prime).
So the problem its sure caused by SUC and the error message is, as so often in Mathcad, misleading/meaningless.
Yes
wrote:
My guess its due to the (fortunate) lack of Static Unit Checking.
Yes, its sure a problem with the unit used and SUC
Yes! r and V must have same dimension. In Mathcad 15 not Prime!
> Yes! r and V must have same dimension. In Mathcad 15 not Prime!
No! Thats not the cause of the error in MC15.
Look at my EDITED answer above - the cause is that you need to provide a unit-compatible return value also for the fictive case that the loop will end regularily. The units of V have nothing to do with that.