unexpected order of evaluation

General FreeBASIC programming questions.
dodicat
Posts: 8137
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: unexpected order of evaluation

Post by dodicat »

srvaldez
Please remember that when you are trying to get ArcCot working in bigfloat-05 that the last arccot should be - Arccot (-20, 239).
You have - Arccot (20, 239).
The value of x in that function immediately is
-.10000000000000000000000000000000000000000000000000000000000000e-00017
after
x=1 : x=x/d
which throws everything off.
I messed about a bit, but couldn't get x to be .0041841004184100418410041841004184100418410041841004 or thereabouts which it should be.
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Re: unexpected order of evaluation

Post by srvaldez »

dodicat
I am confused, I just downloaded my program from the link that I posted, set the precision to 1000 and checked the result against that given by the pari/gp calculator http://pari.math.u-bordeaux.fr/, the relative error was -5.003865326277570842 E-1007
would you please re-download the program and try again ?
let me know what happens

<edit> the reason that I do x=1 : x=x/d is so that x will be set to bigfloat 1, a bigfloat divided by an integer will give full bigfloat precision, but x=1/d will set x to the double precision of 1/d
you could do x=bigfloat(1)/d and it would work
you can also use quoted literals to assign bigfloat constants to a bigfloat variable: x="1" for example
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Re: unexpected order of evaluation

Post by srvaldez »

also, in the arccot example function I used the non-overloaded multiply and divide so that I could limit the precision and speed things up
I implemented that trick in the fpatn function and for precision 2000 or greater it's significantly faster than without the trick
dodicat
Posts: 8137
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: unexpected order of evaluation

Post by dodicat »

I downloaded again.
result:

Code: Select all

NUMBER_OF_DIGITS =  50
d =  239
lim= 12
pr= 0.4326756663205261
d =  57
lim= 15
pr= 0.3461405330564209
d =  18
lim= 21
pr= 0.2472432378974435
 -.10000000000000000000000000000000000000000000000000000000000000e-00019
 0.003606299869716167
 
This is with 64 bit windows compiler.
The 32 bit compiler:below

Code: Select all

NUMBER_OF_DIGITS =  50
d =  239
lim= 12
pr= 0.4326756663205261
d =  57
lim= 15
pr= 0.3461405330564209
d =  18
lim= 21
pr= 0.2472432378974435
 -.10000000000000000000000000000000000000000000000000000000000000e-42949672
 0.003194000224539195
 
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Re: unexpected order of evaluation

Post by srvaldez »

dodicat
since the compile command is at the top of file via #cmdline I can discount that as the problem, what version of FB are you using?
dodicat
Posts: 8137
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: unexpected order of evaluation

Post by dodicat »

I as using 1.10.1
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Re: unexpected order of evaluation

Post by srvaldez »

I just downloaded FB-1.10.1-mingw-w64 gcc 11.2.0 and had no problem, I am stumped, try the following and tell me what you get
? pie-"3.14159265358979323846264338327950288419716939937510582096978610"
instead of ? pie

my suspicion is that the conversion to string is not working right, my guess is that it could be because of different text encoding
try compiling from the CLI
dodicat
Posts: 8137
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: unexpected order of evaluation

Post by dodicat »

It just freezes.
I tried with 1.2 (version shown at the end), not subtracting the string

Code: Select all

NUMBER_OF_DIGITS =  50
d =  239
lim= 12
pr= 0.4326756663205261
d =  57
lim= 15
pr= 0.3461405330564209
d =  18
lim= 21
pr= 0.2472432378974435
 -.10000000000000000000000000000000000000000000000000000000000000e-42949672
 0.00383829977363348
1.20.0
 
I have a command line editor, still the same direct from command line.
Last edited by dodicat on Sep 11, 2024 19:39, edited 1 time in total.
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Re: unexpected order of evaluation

Post by srvaldez »

compile the original file from the download using the CLI
I think that your editor is changing the text encoding and causing problems
dodicat
Posts: 8137
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: unexpected order of evaluation

Post by dodicat »

I tried notepad, wordpad, and direct command line.
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Re: unexpected order of evaluation

Post by srvaldez »

Ok, last resort
here's the compiled executable https://u.pcloud.link/publink/show?code ... 2sAhGYURL7
be sure to check for viruses :D
I forgot to put a sleep at the end so run from the console
dodicat
Posts: 8137
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: unexpected order of evaluation

Post by dodicat »

I used the built in
i=__builtin_clz(fac3(0))
instead of the naked asm.
OK now.

Code: Select all

 NUMBER_OF_DIGITS =  50
d =  239
lim= 12
pr= 0.4326756663205261
d =  57
lim= 15
pr= 0.3461405330564209
d =  18
lim= 21
pr= 0.2472432378974435
 3.14159265358979323846264338327950288419716939937510582096978610e+00000
 0.003082999959588051
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Re: unexpected order of evaluation

Post by srvaldez »

Ok, will change that
thanks dodicat for the debug session 😁
now the question is why the naked function didn't work for you 🤔
dodicat
Posts: 8137
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: unexpected order of evaluation

Post by dodicat »

probably because I am sitting here with my clothes on.
srvaldez
Posts: 3505
Joined: Sep 25, 2005 21:54

Re: unexpected order of evaluation

Post by srvaldez »

🤣🤣🤣
Post Reply