> Interesting. Does this imply that the 50g numeric math library will be running under Saturn emulation while the CAS will not? Or was the math library ported to native code?
No emulation. There was a C version of the HP math library created back for the original 10bII (I think it was a assembly->C converter program type thing - long before my time).
It was later redone to be more "C" like for maintainability with the 20b where a pure C library was used. Still is BCD based, but now totally portable and easy to maintain. Since then it was used in the 39gII where it was expanded and improved upon.
> Good deal. Thanks for making these more consistent with expected behavior.
Yeah, I never liked that either myself. Understand why it was done that way though.
> As much as I like programming in RPL, I think making the programming language more like Pascal while still allowing RPN (RPL?) for interactive use is probably a good choice for the education market.
Yeah. I personally like RPL type programming myself, but I also do recognize that while it excels at allowing quick little stub routine to automate calculations, it really is very difficult to understand weeks/months later when you want to edit it and expand/modify things. Usually, you have to step through and watch the stack or use a piece of paper for anything slightly complicated.
You can still make little stub "functions" very easily by using the "Define" button. Basically, you type in an expression/forumla, select which inputs are meant to be taken as arguments, press OK and you've generated a user function that can be used anywhere, plotted and so on.
A larger more complicated program can look like below. Thanks go to the person that wrote this (they are under a CDA agreement so I won't name them here).
Everything past the line is a copy/paste from the program file you edit on the calculator. Comments are not lost on compile! :-)
TW
-----------------------------------------------------------
// Mandelbrot set for the HP Prime
// Date : April 2013
// Version 1.0
iteration(c, bailoutValue, maxIter)
BEGIN
LOCAL iter := 0;
LOCAL z := (0,0);
WHILE (ABS(z) <= bailoutValue) AND (iter < maxIter) DO
z := z*z+c;
iter := iter+1;
END;
RETURN iter;
END;
LSclr(Ndx)
BEGIN
Ndx := ROUND(Ndx*186,0);
IF Ndx < 31 THEN RETURN 0+ 1*Ndx; END;
IF Ndx < 62 THEN RETURN 31+ 32*(Ndx-31); END;
IF Ndx < 93 THEN RETURN 1023- 1*(Ndx-62); END;
IF Ndx < 124 THEN RETURN 992+ 1024*(Ndx-93); END;
IF Ndx < 155 THEN RETURN 32736- 32*(Ndx-124); END;
IF Ndx < 186 THEN RETURN 31744+ 1*(Ndx-155); END;
RETURN 31775;
END;
colorize(itVal, maxIt)
BEGIN
IF itVal==maxIt THEN
// we're inside the Mandelbrot map
// so draw the pixel in black
RETURN 0;
ELSE
RETURN LSclr(itVal/maxIt);
END;
END;
EXPORT Mandelbrot()
BEGIN
// clear the screen (G0):
RECT();
LOCAL dx, dy, c, xp, yp;
LOCAL iter, color;
// these 4 variables define
// our window of the complex
// plane:
LOCAL xmin, xmax, ymin, ymax;
LOCAL maxIterations := 50;
LOCAL maxRadius := 2;
// Location
// ratio width:height should be 4:3
xmin := -2.5;
xmax := 1.5;
ymin := -1.5;
ymax := 1.5;
// another nice set of parameters:
//xmin := 0.315625;
//xmax := 0.515625;
//ymin := 0.28125;
//ymax := 0.43125;
dx := (xmax-xmin)/320;
dy := (ymax-ymin)/240;
c := (xmin,ymin);
// we loop over every pixel
// of the Prime's screen:
FOR yp FROM 0 TO 239 DO
FOR xp FROM 0 TO 319 DO
// create the complex number c
// we need for the iteration:
c := (xmin+xp*dx, ymax-yp*dy);
// now iterate the formula and
// get back the number of
// iteration steps it took until
// the complex number jumped out
// of the convergence radius:
iter := iteration(c, maxRadius, maxIterations);
// determine a color for this iteration number:
color := colorize(iter, maxIterations);
// set the pixel in that color:
PIXON_P(xp, yp, color);
END;
END;
// leave the image on the screen
// until a key is pressed:
REPEAT UNTIL GETKEY() == -1;
FREEZE;
END;