mpdecimal for Windows

Headers, Bindings, Libraries for use with FreeBASIC, Please include example of use to help ensure they are tested and usable.
Post Reply
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

mpdecimal for Windows

Post by srvaldez »

I built the Windows libraries of mpdecimal for anyone interested
Last edited by srvaldez on Oct 31, 2021 12:03, edited 2 times in total.
deltarho[1859]
Posts: 4308
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: mpdecimal for Windows

Post by deltarho[1859] »

I had a bit of a struggle to get the required files into a folder so that FB could find them. Anyway, I got there.

FB hasn't got a log base 10 but there is an example in the manual to achieve that and I got log base 10 of 8 as 0.9030899869919434.

Code: Select all

The 'ke!san Online Calculator' gave me 0.9030899869919435856412
Your build (50 sig figs) gave me       0.90308998699194358564121668417347908030456964438633
and we can have arbitrary precision?

I expected mpDecimal-test.exe to take a while but it came in faster than I can blink.

WOW! The mind boggles.

Well done, srvaldez. Image
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: mpdecimal for Windows

Post by srvaldez »

@deltarho[1859]
thank you for testing :smile:
jdebord
Posts: 547
Joined: May 27, 2005 6:20
Location: Limoges, France
Contact:

Re: mpdecimal for Windows

Post by jdebord »

Just downloaded. Not yet tested ...

The web site for mpdecimal is here:

http://www.bytereef.org/mpdecimal/index.html

EDIT. Tested now. The two demo programs work well. The DLL too, but the file name (libmpdec.so.2.5.0) cannot be modified.
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: mpdecimal for Windows

Post by dodicat »

Hi srvaldez
I keep going to your download link (Dark page with the filename at the top left), but I always get that little win 10 waiting circle going round and round.
Maybe it is because of the slow broadband connection here.
I'll keep trying.
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: mpdecimal for Windows

Post by srvaldez »

try again, I uploaded it to GitHub and updated the link
dodicat
Posts: 7983
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: mpdecimal for Windows

Post by dodicat »

Thanks srvaldez.
I'll test it later.
deltarho[]
fb has log10

Code: Select all

 
#include "crt.bi"

print log10f(8)
print log10(8)

sleep
 
I also read this:
Benford’s Law,states that the fractional part of the logarithm of random data is uniformly distributed between 0 and 1.
So, for instance, in a set of figures taken from real life, 1 is by far the most common first digit.
This has a neat application in fraud detection, in that most people ignore Benford’s Law when making up figures, and create their first digits in equal numbers.
deltarho[1859]
Posts: 4308
Joined: Jan 02, 2017 0:34
Location: UK
Contact:

Re: mpdecimal for Windows

Post by deltarho[1859] »

dodicat wrote:fb has log10
Thanks for that.
hhr
Posts: 208
Joined: Nov 29, 2019 10:41

Re: mpdecimal for Windows

Post by hhr »

Code: Select all

''=============================================================================
#include "mpdecimal.bi"

'we need to initialize mpd_context before including the overloded operators
Dim Shared As mpd_context_t mpd_context
mpd_init(@mpd_context, 8)

#include "mpdoverload.bi" 'mpdecimal overloaded operators
''=============================================================================
mpd_context.prec = 32
Dim As mpd summand, sum, n, ten

sum = 0
n = 0
ten = 10

Do ' Bellard's formula
   sum += (-32/(4*n+1)-1/(4*n+3)+256/(10*n+1)-64/(10*n+3)-4/(10*n+5)-4/(10*n+7)+1/(10*n+9)) / (1024^n)
   n += 1
   summand = -(-32/(4*n+1)-1/(4*n+3)+256/(10*n+1)-64/(10*n+3)-4/(10*n+5)-4/(10*n+7)+1/(10*n+9)) / (1024^n)
   sum += summand
   n += 1
Loop While Abs(summand) > ten^(-mpd_context.prec)
sum /= 64

Print sum
Print "press any key to exit ";
Sleep

srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: mpdecimal for Windows

Post by srvaldez »

@hhr
nice example :-)
Andrew Lindsay
Posts: 17
Joined: Jan 08, 2016 20:33

Re: mpdecimal for Windows

Post by Andrew Lindsay »

Does anyone have a copy of the Bi and DLL for this?

I'd love to have a copy if anyone can oblige.

Regards

Andrew
srvaldez
Posts: 3379
Joined: Sep 25, 2005 21:54

Re: mpdecimal for Windows

Post by srvaldez »

hi Andrew Lindsay
link above updated, try again
Andrew Lindsay
Posts: 17
Joined: Jan 08, 2016 20:33

Re: mpdecimal for Windows

Post by Andrew Lindsay »

Thanks, that’s greatly appreciated.
Post Reply