Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-27 Thread Dave Korn
On 26/02/2010 19:24, Ian Lance Taylor wrote: Paolo Carlini paolo.carl...@oracle writes: I'm trying to simplify somewhat code in the library hashing floating point numbers, and I would find very useful a simple recipe giving the total number of bits actually used by a long double: the basic

[RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
Hi, I'm trying to simplify somewhat code in the library hashing floating point numbers, and I would find very useful a simple recipe giving the total number of bits actually used by a long double: the basic issue is that for formats like the 80-bit Intel, I can't just rely on sizeof, because the

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Andreas Schwab
Paolo Carlini paolo.carl...@oracle.com writes: At the moment I'm trying to cook up something fixing that count with LDBL_MANT_DIG, but maybe there is something simpler, maybe using preprocessor builtins?!? What's wrong with LDBL_MANT_DIG? Andreas. -- Andreas Schwab, sch...@linux-m68k.org

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 01:03 PM, Andreas Schwab wrote: Paolo Carlini paolo.carl...@oracle.com writes: At the moment I'm trying to cook up something fixing that count with LDBL_MANT_DIG, but maybe there is something simpler, maybe using preprocessor builtins?!? What's wrong with LDBL_MANT_DIG?

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Ed Smith-Rowland
Paolo Carlini wrote: On 02/26/2010 01:03 PM, Andreas Schwab wrote: Paolo Carlini paolo.carl...@oracle.com writes: At the moment I'm trying to cook up something fixing that count with LDBL_MANT_DIG, but maybe there is something simpler, maybe using preprocessor builtins?!?

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Ed Smith-Rowland
Ed Smith-Rowland wrote: Paolo Carlini wrote: On 02/26/2010 01:03 PM, Andreas Schwab wrote: Paolo Carlini paolo.carl...@oracle.com writes: At the moment I'm trying to cook up something fixing that count with LDBL_MANT_DIG, but maybe there is something simpler, maybe using preprocessor

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
Hi, Huh. I would have *sworn* that sizeof(long double) was 10 not 16 even though we know it was 80 bits. normally, it's either 12, for 32-bit machines, or 16, for 64-bit machines. In any case, there are padding bytes, which we don't want to hash. How about (in the language of

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Tim Prince
On 2/26/2010 5:44 AM, Ed Smith-Rowland wrote: Huh. I would have *sworn* that sizeof(long double) was 10 not 16 even though we know it was 80 bits. As you indicated before, sizeof gives the amount of memory displaced by the object, including padding. In my experience with gcc, sizeof(long

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 03:47 PM, Tim Prince wrote: It seems the topic would have been more appropriate for gcc-help, if related to gcc, or maybe comp.lang.c, if a question about implementation in accordance with standard C. It's neither. I was asking for the advice of the compiler people while

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Andreas Schwab
Paolo Carlini paolo.carl...@oracle.com writes: Thanks. Currently I'm thinking of doing something very simple, like: const size_t __size = __LDBL_MANT_DIG__ == 64 ? 10 : sizeof(__val); seems conservative and I think it covers all the cases we really support. What is __size supposed to

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 03:56 PM, Andreas Schwab wrote: Paolo Carlini paolo.carl...@oracle.com writes: Thanks. Currently I'm thinking of doing something very simple, like: const size_t __size = __LDBL_MANT_DIG__ == 64 ? 10 : sizeof(__val); seems conservative and I think it covers all the

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 03:57 PM, Paolo Carlini wrote: On 02/26/2010 03:56 PM, Andreas Schwab wrote: Paolo Carlini paolo.carl...@oracle.com writes: Thanks. Currently I'm thinking of doing something very simple, like: const size_t __size = __LDBL_MANT_DIG__ == 64 ? 10 : sizeof(__val);

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Andreas Schwab
Paolo Carlini paolo.carl...@oracle.com writes: On 02/26/2010 03:56 PM, Andreas Schwab wrote: Paolo Carlini paolo.carl...@oracle.com writes: Thanks. Currently I'm thinking of doing something very simple, like: const size_t __size = __LDBL_MANT_DIG__ == 64 ? 10 : sizeof(__val);

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Andreas Schwab
Paolo Carlini paolo.carl...@oracle.com writes: Andreas, more seriously, if you mean that __CHAR_BIT__ can be != 8, I Don't be silly. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 And now for something completely

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 04:41 PM, Andreas Schwab wrote: Of what? What is the 10 magic number supposed to represent? A size_t. Thus the number of consecutive chars occupied by the long double. By the way, in the meanwhile I grepped config for BITS_PER_UNIT and *finally* there are no 16 or 32 anymore.

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Andreas Schwab
Paolo Carlini paolo.carl...@oracle.com writes: On 02/26/2010 04:41 PM, Andreas Schwab wrote: Of what? What is the 10 magic number supposed to represent? A size_t. Thus the number of consecutive chars occupied by the long double. How does that handle padding? Andreas. -- Andreas

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 04:51 PM, Andreas Schwab wrote: How does that handle padding? Andreas, I can spend the whole afternoon discussing with you one word at a time in a kind of Socratic question and answer exchange. You mean the padding can be *in the middle*? I didn't consider that, seems quite

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Andreas Schwab
Paolo Carlini paolo.carl...@oracle.com writes: You mean the padding can be *in the middle*? I didn't consider that, seems quite crazy to me. How is that crazy in any way? If you are sure, please say it, let's skip those 2 or 6 bytes, and be done with it. I have the patch otherwise ready.

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
Ok, patch canceled. Paolo.

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 05:03 PM, Andreas Schwab wrote: If you don't care about internal padding why do you care about padding By the way, this doesn't make any sense to me: I don't see what the CPU gains from having padding between mantissa and exponent, or different bytes of the mantissa. If you really

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Dave Korn
On 26/02/2010 15:45, Paolo Carlini wrote: On 02/26/2010 04:41 PM, Andreas Schwab wrote: Of what? What is the 10 magic number supposed to represent? A size_t. Thus the number of consecutive chars occupied by the long double. By the way, in the meanwhile I grepped config for BITS_PER_UNIT

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Andreas Schwab
Paolo Carlini paolo.carl...@oracle.com writes: By the way, this doesn't make any sense to me: I don't see what the CPU gains from having padding between mantissa and exponent, or different bytes of the mantissa. It's a fact of life. I didn't design the motorola floating point format. If

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 05:36 PM, Andreas Schwab wrote: See libiberty/floatformat.c. Ok, thanks. Actually, it looks like there is *no* padding in the middle for the Intel x87 format I truly care about: const struct floatformat floatformat_i387_ext = { floatformat_little, 80, 0, 1, 15, 0x3fff,

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Andreas Schwab
Paolo Carlini paolo.carl...@oracle.com writes: But really we don't want to deal with all those special cases for other formats, for now at least. Too bad. But LDBL_MANT_DIG == 64 is ambigous for identifying the floating point format. Andreas. -- Andreas Schwab, sch...@linux-m68k.org GPG Key

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Daniel Jacobowitz
On Fri, Feb 26, 2010 at 06:09:37PM +0100, Paolo Carlini wrote: On 02/26/2010 05:36 PM, Andreas Schwab wrote: See libiberty/floatformat.c. Ok, thanks. Actually, it looks like there is *no* padding in the middle for the Intel x87 format I truly care about: const struct floatformat

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 07:05 PM, Andreas Schwab wrote: But really we don't want to deal with all those special cases for other formats, for now at least. Too bad. But LDBL_MANT_DIG == 64 is ambigous for identifying the floating point format. Sure, sure. I meant, there are too many formats and

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Paolo Carlini
On 02/26/2010 07:07 PM, Daniel Jacobowitz wrote: Despite all that exchange, I don't think you ever answered Andreas's question - at least not in a way that I could understand. A size of what? The size of the *type* on x86 is 16; the size of the *data bits* is 10. But what cares about the

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Andreas Schwab
Paolo Carlini paolo.carl...@oracle.com writes: I'm tired. Anyway, I meant of course the size of the *data bits*, using your terminology. For *some* formats, like x87, where there are no holes, no padding bits in the middle of the representation, that is all I would need. In the meanwhile,

Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread Ian Lance Taylor
Paolo Carlini paolo.carl...@oracle.com writes: I'm trying to simplify somewhat code in the library hashing floating point numbers, and I would find very useful a simple recipe giving the total number of bits actually used by a long double: the basic issue is that for formats like the 80-bit

Re: Re: [RFH] A simple way to figure out the number of bits used by a long double

2010-02-26 Thread 3dw4rd
Feb 26, 2010 01:43:15 PM, sch...@linux-m68k.org wrote: Paolo Carlini writes: I'm tired. Anyway, I meant of course the size of the *data bits*, using your terminology. For *some* formats, like x87, where there are no holes, no padding bits in the middle of the representation, that is all