This is an interesting idea. Certainly, the concept of infinity is worth exploring and LOGO, as a general tool for exploring ideas, should be able to do it.
Currently, FMSLogo has no special handling for infinity. What you see comes from the GNU C library from MingGW (32bit), which is slightly different than what the Borland C library did. All the behavior that you see is purely accidental. For FMSLogo to really support infinity, it would provide a name for it, so you could reference it directly. It would also have defined behavior for procedures which accept numbers (even if it's just to throw a PROC doesn't like infinity as input error).
I don't think that infinity is the correct output from POWER 10 999. That should be a very big number, but FMSLogo doesn't have built-in support for very big numbers. Interestingly, on Fedora 35 (the Linux distro that I'm writing this on), POWER 10 999 throws a "POWER doesn't like 999 as input" error. I prefer this behavior than returning a number that's not really a number, even though my preference would preclude this way of exploring infinity. Maybe there's a more LOGO-like way to explore infinity that's rooted in number theory, not the IEEE floating point number specification. I think the most LOGO-like way, using turtle graphics, won't work for FMSLogo because it uses a discrete raster as its drawing surface; plotting "f(x) = (1 / x)" would become exactly 0 for not-so-large x.
For the behavior of POWER 0 0 see Bug #73. At one point, I thought it should output 1 but was convinced otherwise. I respect Donald Knuth's authority, but I think he just wanted a convenient definition for writing simpler proofs.
Was reading and exploration of infinity and NaN with the J programming language
https://mlliarm.github.io/jmath/articles/01_Exploring_infinity.html
And got curious about how Logo handles those cases.
I don't remember NaN ever mentioned in the FMSLogo's Help, but I have noticed that FMSLogo does produce "inf" sometimes:
I was impressed with how well FMSLogo deals with infinity, except for these cases
It seems to me that, to be consistent, the following ones should raise an error:
And this one should output 1 because Donald Knuth says so :)
https://en.wikipedia.org/wiki/Zero_to_the_power_of_zero#Current_situation
Another case which is interesting is 0 / 0
There is this argument for allowing it to be 1:
http://computer-programming-forum.com/9-apl/f51f62b466b7f317.htm
and I have adopted that idea in LogoFE, but I think I'm ok with FMSLogo doing what it currently does.
-inf should also be considered. For example, this should probably raise an error too:
It seems the IEEE says the result will be NaN:
So since FMSLogo seems to avoid dealing with NaN's, the operation shouldn't be allowed.
Last edit: DanielAjoy 2022-01-21
This is an interesting idea. Certainly, the concept of infinity is worth exploring and LOGO, as a general tool for exploring ideas, should be able to do it.
Currently, FMSLogo has no special handling for infinity. What you see comes from the GNU C library from MingGW (32bit), which is slightly different than what the Borland C library did. All the behavior that you see is purely accidental. For FMSLogo to really support infinity, it would provide a name for it, so you could reference it directly. It would also have defined behavior for procedures which accept numbers (even if it's just to throw a
PROC doesn't like infinity as input
error).I don't think that infinity is the correct output from
POWER 10 999
. That should be a very big number, but FMSLogo doesn't have built-in support for very big numbers. Interestingly, on Fedora 35 (the Linux distro that I'm writing this on),POWER 10 999
throws a "POWER doesn't like 999 as input" error. I prefer this behavior than returning a number that's not really a number, even though my preference would preclude this way of exploring infinity. Maybe there's a more LOGO-like way to explore infinity that's rooted in number theory, not the IEEE floating point number specification. I think the most LOGO-like way, using turtle graphics, won't work for FMSLogo because it uses a discrete raster as its drawing surface; plotting "f(x) = (1 / x)" would become exactly 0 for not-so-large x.For the behavior of
POWER 0 0
see Bug #73. At one point, I thought it should output 1 but was convinced otherwise. I respect Donald Knuth's authority, but I think he just wanted a convenient definition for writing simpler proofs.Related
Bugs:
#73