This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.

Index Nav: Message Nav: [Date Index] [Subject Index] [Author Index] [Thread Index] [Date Prev] [Date Next] [Thread Prev] [Thread Next] [Raw text]

# Re: [PATCH v2] Use long for mantissa for generic mp code

• From: Siddhesh Poyarekar <siddhesh dot poyarekar at gmail dot com>
• To: Richard Henderson <rth at twiddle dot net>
• Cc: Siddhesh Poyarekar <siddhesh at redhat dot com>, libc-alpha at sourceware dot org
• Date: Thu, 14 Mar 2013 07:55:41 +0530
• Subject: Re: [PATCH v2] Use long for mantissa for generic mp code

```On 13 March 2013 22:16, Richard Henderson <rth@twiddle.net> wrote:
>> +/* Divide D by RADIX and put the remainder in R.  D must be a non-negative
>> +   integral value.  */
>> +  ({                                                                       \
>> +    r = ((uint64_t) d) % RADIX;                                                            \
>> +    d /= RADIX;                                                                    \
>> +  })
>
> One unsigned divide and one signed divide is even worse than two signed
> divides, surely.  Perhaps it would be easier to just write

The code ran faster with this and I was careless and didn't check what
the generated assembly looked like.

>     r = d & (RADIX - 1);
>
> or whatever?  Or just give up on being able to avoid the signed divide?

Right, I could just do this.

>> +
>> +/* Put the integer component of a double X in R and retain the fraction in
>> +   X.  */
>> +#define INTEGER_OF(x, i) \
>> +  ({                                                                       \
>> +    i = (mantissa_t) x;                                                            \
>> +    x -= i;                                                                \
>> +  })
>
> We need a better comment here, since we're no longer talking about doubles.

Oh but X *is* a double here.  This is used in construction of a
multiple precision number from a double where we repeatedly get the
integer portion of the double and scale the fractional part by RADIX
to get a mantissa digit.  Would it be sufficient if I add this
explanation?

Siddhesh
--
http://siddhesh.in

```

Index Nav: Message Nav: [Date Index] [Subject Index] [Author Index] [Thread Index] [Date Prev] [Date Next] [Thread Prev] [Thread Next]