jmoenig / Snap

a visual programming language inspired by Scratch
http://snap.berkeley.edu
GNU Affero General Public License v3.0
1.48k stars 739 forks source link

Rationalize Floating Point Errors? #350

Open cycomachead opened 10 years ago

cycomachead commented 10 years ago

This was suggested as an idea from #348 by @brianharvey. I definitely think it's worth considering, so I'm going to post this here (since the other issue is closed).

Here's what was said:

@brianharvey:

We /could/ convert numbers to the simplest rational form within some epsilon of the given number. See the RATIONALIZE function here, for example: https://www.gnu.org/software/mit-scheme/documentation/mit-scheme-ref/Numerical-operations.html. (Note: Numerical analysts such as Prof. Kahan would be very upset by this; there are good reasons why it's a bad idea if several transcendental functions are composed and you simplify in the middle. But for kids, or even BJC students, it might still be desirable.)

Me:

Yeah, the thought of doing something similar did occur to me, but I've not had enough experience with floating point to know if that'd cause more trouble than it's worth. I did just test with scratch and it seems to be rounding off for some cases, and I do agree that for BJC students that it's an acceptable practice. However, I do think it should be worth carefully considering since if students start to use Snap for more advanced projects, or data analysis (very real possibly given AP CSP) then would we see too many ill side-effects? You'd have a much better answer / guess than I would.

brianharvey commented 10 years ago

I think it would be okay if we did this only when values are displayed, but not internally. Good student project.

cycomachead commented 10 years ago

I think it would be okay if we did this only when values are displayed, but not internally.

Wise idea. :) I like this!

@marwahaha This might be tackle-able if we allow libraries in Snap!.