Page 1 of 1

r10 procedures by tejon

Posted: Fri Oct 24, 2003 5:21 pm
by MikeB
Is anybody else using these procedures and have they found the same bug that I have found?

To simplify using these marvelous procedures for getting double precision accuracy, I wrote my own procedures which basically are along the lines of answer$=MyMul(a$,b$) which then calls the r10 procedures to convert the two strings, mutiply them, convert back and return the answer as a string. I have similar procedures for all the functions so that by including his and mine in a program I call them as required.

But - I discovered that although the results seem to be always numerically correct I never got a negative answer. So that -7+2=5 for example.

I have corrected this by adding this bit to the end of the original Procedure.s r10ftoa(*x.r10,format.l)

If s=-1 ; added by me
If Left(f$,1)<>"-" ; since there are if s=-1 bits in the prog I don't want two minus signs if one does get added
f$="-"+f$ ; added by me
EndIf ; added by me
EndIf ; added by me
ProcedureReturn f$
EndProcedure

Which seems to have worked and I now get correct answers displayed, but I don't know why it is needed since there are several If s=-1 : f$="-"+f$ : EndIf bits in the original procedure. My problem being that the ASM bits are a bit of a foreign language to me, I used to understand the 68000 series code, but stick to PB since changing to Windows!

MikeB

Posted: Sat Oct 25, 2003 4:47 am
by tejon
hello MikeB, i wrote a math eval procedure that you can have if you want.
it allows you to do things like:
x$=eval("a=1+2*3") ;x$ now holds "7"
z$=eval("a") ;z$ now holds "7" as well

operators and functions supported:
unary +,-
+,-,*,/,^,! (! = factorial)
____________________________________________________________
operator precedence highest to lowest
! (gamma(1+x) if fractional)
^
*,/
unary +,-
+,-
and of course, parenthesis ().
____________________________________________________________
functions:
sin,cos,tan,asin,acos,atan,sqrt,sqr,ln,exp,log,alog,sinh,cosh,tanh,asinh,acosh,atanh
____________________________________________________________
variables:
A thru Z, (case insensitive)
____________________________________________________________
constants:
#pi,#e
____________________________________________________________
@ holds the previous evaluation

the eval procedure works well as it is, but i was thinking about adding
logical operators like: <,>,<=,>=,= which would make the procedure
more useful.

Posted: Sat Oct 25, 2003 4:07 pm
by MikeB
Thanks tejon, yes I would like to try your eval() procedure if you let me know where to download from. I tried on the resources site but did not find anything.

MikeB

Posted: Sat Oct 25, 2003 5:20 pm
by tejon
check your PM inbox.

-tejon

Posted: Mon Oct 27, 2003 1:26 pm
by MikeB
Thanks tejon, this is just what I needed. I have written a program that is like a specialised scientific calculator that lets you enter strange conversions that I use regularly, but would probably seem a weird collection to anybody else, which worked very well with your original routines. Now that I have your eval() routine I am modifying the GUI to allow the entry of longer input, so that as well as my own routines which I am altering to use eval() in a single step instead of a string of consecutive steps, it can also perform complex calculations entered directly while having the big advantage of having the formula used displayed as one line, making a check for mistakes in entry easy to see and easy to correct without having to re-enter the whole thing.

MikeB

Posted: Thu Oct 30, 2003 6:27 pm
by geoff
MikeB wrote: Is anybody else using these procedures and have they found the same bug that I have found?
Sorry Mike, I added these format options to tejon's procedure and omitted one line from the (last) fixed significant figures option. You need to insert one line before the last 4 lines of the procedure. The change you have made has the same effect.

The last 5 lines of the procedure are then:

Code: Select all

   If s=-1: f$="-"+f$:EndIf;====the missing line====
 EndIf 
 r10copy(*x,@xtem);restore *x after use by bcd pack
 ProcedureReturn f$ 
EndProcedure 
Incidentally MikeB, I'm also -- Joined 27 Apr, UK Cornwall