Precision Concession
delta trinity
deltatrinity@hotmail.com
Wed, 25 Jun 2003 09:32:43 -0400
This may work. It may actually size down the mpf_t struct to desired
precision. But, ont thing, instead of (sizeNew * sizeof(mp_ptr) * 8), you
should use (sizeNew * __GMP_BITS_PER_MP_LIMB), since the structure is made
of mp_limb_t and not mp_ptr, and there could be fewer bits per limbs than 32
bits (in the case of nails, I think) and may be different from
sizeof(mp_ptr).
>From: LingWitt@insightbb.com
>To: LingWitt@insightbb.com
>CC: Kevin Ryde <user42@zip.com.au>, gmp-discuss@swox.com
>Subject: Precision Concession
>Date: Wed, 25 Jun 2003 08:39:00 -0400
>
>How is this:
>
>unsigned int stripLowZeroLimbs(mpf_ptr f)
>{
> unsigned sizeNew, sizeOld;
> sizeNew = sizeOld = f->_mp_size;
> mp_ptr limbs = f->_mp_d;
> mp_ptr limb = 0;
>
> if (sizeNew == 0)
> return 0;
>
> while (*(limb = limbs++) == 0)
> sizeNew--;
>
> if (sizeNew == sizeOld)
> return 0;
>
> mpf_set_prec(f, sizeNew * sizeof(mp_ptr) * 8);
>
> return sizeOld - f->_mp_size;
>}
>
>On Tuesday, Jun 24, 2003, at 23:46 America/New_York, LingWitt@insightbb.com
>wrote:
>
>>This is what you meant:
>>
>>unsigned int stripLowZeroLimbs(mpf_ptr f)
>>{
>> unsigned sizeNew, sizeOld;
>> sizeNew = sizeOld = f->_mp_size;
>> mp_ptr limbs = f->_mp_d;
>> mp_ptr limb = 0;
>>
>> while (*(limb = limbs++) == 0)
>> sizeNew--;
>>
>> if (sizeNew == sizeOld)
>> return 0;
>>
>> f->_mp_size = sizeNew;
>>
>> mp_ptr newLimbs = f->_mp_d;
>> limbs--;
>> for (unsigned int index = 0; index < sizeNew; index++)
>> newLimbs[index] = *(limbs++);
>>
>> return sizeOld - f->_mp_size;
>>}
_________________________________________________________________
Help STOP SPAM with the new MSN 8 and get 2 months FREE*
http://join.msn.com/?page=features/junkmail