Radio UserLand loop has my head spinning

I've run into some unexpected behavior in UserTalk while documenting loop loops for Radio UserLand Kick Start.

The following code ends up with a final displayed value of 3.4 in the About Radio UserLand dialog box:

loop (local (i = 0.1); i <= 3.5; i = i + 0.1) {
msg (i)

If anyone can explain why the final output isn't 3.5, as I expected, I've begun a discussion on the radio-dev mailing list.


I would guess that it's due to the inaccuracy of floating point math.

Interestingly, my copy of Radio Userland 8.0.8 for Mac OS X does return 3.5 when I run that code in a QuickScript.


Add a Comment

All comments are moderated before publication. These HTML tags are permitted: <p>, <b>, <i>, <a>, and <blockquote>. This site is protected by reCAPTCHA (for which the Google Privacy Policy and Terms of Service apply).