Does anyone know of any bignum libraries for pb?
------------------
------------------
;you can download gmp from [url="http://www.cs.nyu.edu/exact/core/gmp/"]http://www.cs.nyu.edu/exact/core/gmp/[/url] Structure mpz ; multiprecision integer mp_alloc.l mp_size.l mp_limb.l EndStructure Structure mpq ; multiprecision rational mp_num.mpz mp_den.mpz EndStructure Structure mpf ; multiprecision floating point mp_prec.l mp_size.l mp_expt.l mp_limb.l EndStructure i.mpz j.mpz k.mpz l.mpz n.mpq m.mpq q.mpq x.mpf y.mpf z.mpf OpenConsole() ConsoleTitle ("GMP.DLL test") If OpenLibrary(1, "GMP.DLL") ; integer ------------------------------------------------------------------------- CallFunction(1,"__gmpz_init",i); initialize integer number i CallFunction(1,"__gmpz_init",j); initialize integer number j CallFunction(1,"__gmpz_init",k); initialize integer number k CallFunction(1,"__gmpz_init",l); initialize integer number k a$="33333333333333333333333333333333333333333333333333333333333333333333333333333" CallFunction(1,"__gmpz_set_str",i,a$,10) ; set i equals to 3333333333... number base 10 CallFunction(1,"__gmpz_set_str",j,a$,10) ; set j equals to 3333333333... number base 10 CallFunction(1,"__gmpz_mul",k,i,j); k= i*j a$=Space(63000);allocate space CallFunction(1,"__gmp_sprintf",a$,"%Zd",k);convert integer to string in a$ PrintN(a$); print integer number CallFunction(1,"__gmpz_fac_ui",k,10); k= ! a$=Space(63000);allocate space al.l=CallFunction(1,"__gmp_sprintf",a$,"%Zd",k);convert integer to string in a$ PrintN(a$); print integer number PrintN(Str(al));number of digits in factorial ; rational ------------------------------------------------------------------------ CallFunction(1,"__gmpq_init",n); initialize rational number n CallFunction(1,"__gmpq_init",m); initialize rational number m CallFunction(1,"__gmpq_init",q); initialize rational number q CallFunction(1,"__gmpq_set_str",n,"4/12",10); set n equals to 4/12 number base 10 (1/3) ;The string can be an integer like "41" or a fraction like "41/152". ;The fraction must be in canonical form (see Chapter 6 [Rational Number Functions], page 42), ;or if not then mpq_canonicalize must be called. CallFunction(1,"__gmpq_canonicalize",n); set n equals to 1/3 number base 10 CallFunction(1,"__gmpq_set_str",m,"1/5",10); set m equals to 1/5 number base 10 CallFunction(1,"__gmpq_add",q,n,m);q=n+m CallFunction(1,"__gmpq_mul_2exp",q,q,128) PrintN("num -> "+Str(q\mp_num\mp_size)) PrintN("den -> "+Str(q\mp_den\mp_size)) ;PrintN(Str((((q\mp_num\mp_size)+(q\mp_den\mp_size))*9.633)+1)) a$=Space(63000);allocate space al.l=CallFunction(1,"__gmp_sprintf",a$,"%Qd",q);convert rational to string in a$ PrintN(Str(al)) PrintN(a$); print rational number ; floating point ------------------------------------------------------------------ CallFunction(1,"__gmpf_init2",x,65536); initialize float number x with 65536 bits precision CallFunction(1,"__gmpf_init2",y,65536); initialize float number y with 65536 bits precision CallFunction(1,"__gmpf_init2",z,65536); initialize float number z with 65536 bits precision CallFunction(1,"__gmpf_set_str",x,"2",10); set x equals to 2 number base 10 CallFunction(1,"__gmpf_sqrt",y,x) ; y = sqrt(x) a$=Space(63000) CallFunction(1,"__gmp_sprintf",a$,"%77.70Fe",y); convert floating point number y to string in a$ PrintN(a$) ; print float number y CallFunction(1,"__gmpf_pow_ui",z,y,2); z=y^2 CallFunction(1,"__gmpf_neg",z,z); z=y^2 a$=Space(63000) CallFunction(1,"__gmp_sprintf",a$,"%77.70Fe",z) PrintN(a$) Print(">> ") b$=Input() CallFunction(1,"__gmpz_clear",i); deallocate memory CallFunction(1,"__gmpz_clear",j) CallFunction(1,"__gmpz_clear",k) CallFunction(1,"__gmpz_clear",l) CallFunction(1,"__gmpq_clear",n) CallFunction(1,"__gmpq_clear",m) CallFunction(1,"__gmpq_clear",q) CallFunction(1,"__gmpf_clear",x) CallFunction(1,"__gmpf_clear",y) CallFunction(1,"__gmpf_clear",z) CloseLibrary(1) EndIf CloseConsole()
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment