Welcome, Guest.
Please login or register.
LONGDOUBLE functions
Forum Login
Login Name: Create a new account
Password:     Forgot password

XBLite Forum    General Boards    XBLite Programming  ›  LONGDOUBLE functions
Users Browsing Forum
No Members and 1 Guests

LONGDOUBLE functions  This thread currently has 2,889 views. Print Print Thread
1 Pages 1 Recommend Thread
sospel
August 21, 2008, 3:51pm Report to Moderator Report to Moderator
Baby Member
Posts: 6
Hello !
Continuing my tests of XBLite, I need mathematical functions for numbers of type " LONGDOUBLE ".
I' ve found all the functions which I need in " XbLite\Programme\xblite\demo\longdouble \xml " ...
except two : the fontion ATANL (inverse of "TANL"), and "EXPL"
I am going to try to write it in ASSEMBLER language , but as I know ~ nothing in this language, I would
be happy if one of you has a reference, a link or a Web site where I could find these 2 functions for
XBLite!!

Thank you in advance for any answer!
Cordially,
Sospel
Logged Offline
Private Message Private message
26
August 22, 2008, 9:02am Report to Moderator Report to Moderator
Guest User
For AtanL, this one seems to work correctly :

Quoted Text
DECLARE FUNCTION  LONGDOUBLE  AtanL (LONGDOUBLE xld)



Quoted Text
'
' ###################
' #####  AtanL  #####
' ###################
'
FUNCTION LONGDOUBLE AtanL (LONGDOUBLE xld)
LONGDOUBLE ln
     
ASM fld t[ebp+8]          ;get param on stack
ASM fld1          ;ST(0)=1.0,ST(1)=param
ASM fpatan     ;compute atan(ST(1)),divide by ST(0) and pop ST(0) so ST(0)=atan(rad)
ASM fstp t[ebp-32]       ;write result on ln
     
RETURN ln

END FUNCTION


Finally found a bit of time and adapted exp from : http://www.jbox.dk/sanos/source/lib/math/exp.asm.html (no pain, first match w/ google )

Quoted Text
DECLARE FUNCTION  LONGDOUBLE  ExpL  (LONGDOUBLE xld)


Quoted Text
'
' ##################
' #####  ExpL  #####
' ##################
'
FUNCTION LONGDOUBLE ExpL (LONGDOUBLE xld)
LONGDOUBLE ln

ASM fld t[ebp+8]     ;get param on stack

ASM fldl2e                          ; Load log base 2(e)
ASM fmulp   st1,st0                ; Multiply x * log base 2(e)
ASM fst     st1                   ; Push result
ASM frndint                         ; Round to integer
ASM fsub    st1,st0                ; Subtract
ASM fxch                            ; Exchange st, st(1)
ASM f2xm1                           ; Compute 2 to the (x - 1)
ASM fld1                            ; Load real number 1
ASM fadd                            ; 2 to the x
ASM fscale                          ; Scale by power of 2
ASM fstp    st1               ; Set new stack top and pop


ASM fstp t[ebp-32]  ;write result on ln


RETURN ln
END FUNCTION


Tested theses funcs quickly but they seem to give correct result.
Logged
E-mail E-mail Reply: 1 - 8
26
August 22, 2008, 9:26am Report to Moderator Report to Moderator
Guest User
Attached modified xml



This post contains attachments; to download them you must login.

Logged
E-mail E-mail Reply: 2 - 8
17
August 22, 2008, 10:10am Report to Moderator Report to Moderator
Guest User
Hi Fano,

So cool! Thanks.

Bye! Guy
Logged
E-mail E-mail Reply: 3 - 8
sospel
August 22, 2008, 12:23pm Report to Moderator Report to Moderator
Baby Member
Posts: 6
Hello FANO !

"longdouble" thanks for your answer : I' ll try these functions to make a test with some functions and their
inverse. Afterwards, I will send results )
Cordially,
SosPel
Logged Offline
Private Message Private message Reply: 4 - 8
sospel
August 28, 2008, 3:02pm Report to Moderator Report to Moderator
Baby Member
Posts: 6
Hello !

I continued the test with the functions to study " LONGDOUBLE " variables . The results are bad!
Here is the test:
I use a benchmark the formulation of which is this one:

      value = 1.0
      FOR i=1  TO 10
         FOR j=1 TO 1000
            FOR k=1 TO 1000
               value = Tan(Atan(Exp(Log(Sqrt(value * value)))))+1.0
            NEXT k
         NEXT j
      NEXT i
      PRINT "value  "; STRING$(value)
      error=(1.0 - value/1.e7) * 100.0
      PRINT "error  "; STRING$(error)
          
      ( Benchmark take in an old "Sky & Telescope" review)

I adapt these instructions according to the used language (ex: in XBLite, I put all the useful functions in
assembler - see precedents posts). All the calculations are made in "DOUBLE PRECISION". Results :

1/in FORTRAN 95         : value = 10000001.000593 , error in % = 0.000010005 [Reference calculation]
2/in GFA-Basic (WinXP) : value = 10000001.001222 , error in % = 0.000010001 [remarkable for a "BASIC"!!]
3/in Visual-Basic 6        : value =  9999818.448501 , error in % = 0.001815515 [acceptable]
4/in Emergence BASIC  : value =  9999818.448501 , error in % = 0.001815515 [NB: idem than VB6].
5/in XBLite D.P            : value =  9999818.448501 , error in % = 0.001815515 [NB: idem than VB6].

But on opposite, the XBLite calculation in LONGDOUBLE is false :

6/in XBLite ( LD.P): value = 2.484822

(maybe I made an error of programming?)
Temporary conclusion: it would be doubtless interesting that somebody bends over these functions in LD,
to bring XBLite at the level of precision of the GFA ???

Cordially
SosPel
Logged Offline
Private Message Private message Reply: 5 - 8
26
August 28, 2008, 6:16pm Report to Moderator Report to Moderator
Guest User
I took 5 mins to look if LDP functions were giving coherents result compared to DP and i noticed a difference between Log and LogL so i edited function and attached xml2.x.As before i found asm funcs there : http://www.jbox.dk/sanos/source/lib/math/ (BSD license)

[fanboy mode]
Prepares to place XBlite 1st
[/fanboy mode]





This post contains attachments; to download them you must login.

Logged
E-mail E-mail Reply: 6 - 8
XBLiteAdmin
August 30, 2008, 11:17pm Report to Moderator Report to Moderator
Administrator Group
Posts: 44
Quoted from sospel
Hello !

I continued the test with the functions to study " LONGDOUBLE " variables . The results are bad!
Here is the test:
I use a benchmark the formulation of which is this one:

      value = 1.0
      FOR i=1  TO 10
         FOR j=1 TO 1000
            FOR k=1 TO 1000
               value = Tan(Atan(Exp(Log(Sqrt(value * value)))))+1.0
            NEXT k
         NEXT j
      NEXT i
      PRINT "value  "; STRING$(value)
      error=(1.0 - value/1.e7) * 100.0
      PRINT "error  "; STRING$(error)
          
      ( Benchmark take in an old "Sky & Telescope" review)

I adapt these instructions according to the used language (ex: in XBLite, I put all the useful functions in
assembler - see precedents posts). All the calculations are made in "DOUBLE PRECISION". Results :

1/in FORTRAN 95         : value = 10000001.000593 , error in % = 0.000010005 [Reference calculation]
2/in GFA-Basic (WinXP) : value = 10000001.001222 , error in % = 0.000010001 [remarkable for a "BASIC"!!]
3/in Visual-Basic 6        : value =  9999818.448501 , error in % = 0.001815515 [acceptable]
4/in Emergence BASIC  : value =  9999818.448501 , error in % = 0.001815515 [NB: idem than VB6].
5/in XBLite D.P            : value =  9999818.448501 , error in % = 0.001815515 [NB: idem than VB6].

But on opposite, the XBLite calculation in LONGDOUBLE is false :

6/in XBLite ( LD.P): value = 2.484822

(maybe I made an error of programming?)
Temporary conclusion: it would be doubtless interesting that somebody bends over these functions in LD,
to bring XBLite at the level of precision of the GFA ???

Cordially
SosPel


Hi,

I believe the trouble is just with the naming convention used in the xml library. The LogL function should really be named Log10L, and the LnL should be LogL. So for your test above, use LnL instead of LogL.

When using the correct functions, I got the folowing results from the benchmark:

value  1.000000100111374133d+7
error  -1.001113741329546017d-5

I will correct the functions names in xml so they correspond correctly with the xma functions.

ciao,
D.
Logged Offline
Site Site Private Message Private message Reply: 7 - 8
sospel
September 1, 2008, 8:06pm Report to Moderator Report to Moderator
Baby Member
Posts: 6
Hello !

Thanks to D. Administrator : I' ve changed LnL in formula and now, I have same excellent results.
Well, Xblite is as well good as GFA !!
Now, I go to another programs ...

Cordially,
SosPel


              
Logged Offline
Private Message Private message Reply: 8 - 8
1 Pages 1 Recommend Thread
Print Print Thread

XBLite Forum    General Boards    XBLite Programming  ›  LONGDOUBLE functions

Thread Rating
There is currently no rating for this thread