New to Py 3.3.3 having prob. with large integer div. float.
casevh at gmail.com
casevh at gmail.com
Tue Feb 11 08:24:01 CET 2014
On Monday, February 10, 2014 6:40:03 PM UTC-8, hlauk.h... at gmail.com wrote:
> I am coming off Python 2.6.6 32 bite platform and now in win 8.1 64 bite.
> I had no problems with gmpy in 2.6.6 and large integer floating points where
> you could control the length of the floating point by entering the bite size
> of the divisor(s) you are using. That would give the limit length of the float
> in the correct number of bites.
> In Python 3.3.3 and gmpy2 I have tried many things in the import mpfr module
> changing and trying all kinds of parameters in the gmpy2 set_context module
> and others.
> The best I can get without an error is the results of a large integer
> division is a/b = inf. or an integer rounded up or down.
> I can't seem to find the right settings for the limit of the remainders in the
> My old code in the first few lines of 2.6.6 worked great and looked like this -
> import gmpy
> BIG =(A large composite with 2048 bites)
> SML =(a smaller divisor with 1024 bites)
> Y= gmpy.mpz(1)
> A= gmpy.mpf(1)
> x=+ gmpy.next.prime(x)
> while y < 20:
> B = gmpy.mpf(x.1024)
> ## the above set the limit of z/b float (see below) to 1024
> if d = <.00000000000000000000000000000000001:
> proc. continues from here with desired results.
> gmpy2 seems a lot more complex but I am sure there is a work around.
> I am not interested in the mod function.
> My new conversion proc. is full of ## tags on the different things
> I tried that didn't work.
The following example will divide two integers with a result precision
of 1024 bits:
# Set mpfr precision to 1024
# Omitting code....
a = gmpy2.mpz(SML)/gmpy2.mpz(x)
Python 3.x performs true division by default. When integer division involves
an mpz, the result will be an mpfr with the precision of the current context.
Does this help?
More information about the Python-list