* RFA: patch to convert_doublest_to_floatformat in doublest.c
@ 2003-06-10 19:16 J. Johnston
2003-06-11 21:20 ` Kevin Buettner
2003-06-11 22:15 ` Kevin Buettner
0 siblings, 2 replies; 5+ messages in thread
From: J. Johnston @ 2003-06-10 19:16 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 1322 bytes --]
The attached patch fixes a bug in convert_doublest_to_floatformat when converting
to a IEEE single float format that has an implied integer bit.
The problem is that the code is performing a shift to discard the top bit.
It then subtracts one from the number of mantissa bits. Later on, the
code does a shift of 32 - mantissa_bits to the right, then puts "mant_bits"
into the result.
For a single float, we have 23 bits of mantissa. If we shift the value, we
still have 23 bits to put into the result. According to the algorithm, we
will only put 22 bits and will shift 10 bits to the right, thereby losing the
last bit.
This in fact, causes the error for Bugzilla bug 85109 whereby p print_two_floats(*f3)
in call-rt-st.exp does not print one of the values correctly. It is in fact printing
what is given to it which has the last bit zeroed out.
The old algorithm is correct for floating values whereby there are 32 or more mantissa
bits. In such a case, we only can put 31 bits into the result. A simple test
was added. The patch has been tested on the ia64 and x86.
Ok to commit?
-- Jeff J.
2003-06-10 Jeff Johnston <jjohnstn@redhat.com>
* doublest.c (convert_doublest_to_floatformat): When dealing with the implied
integer bit, only alter mant_bits if we are processing a full 32 bits of
mantissa.
[-- Attachment #2: doublest.patch --]
[-- Type: text/plain, Size: 1003 bytes --]
Index: doublest.c
===================================================================
RCS file: /cvs/src/src/gdb/doublest.c,v
retrieving revision 1.15
diff -u -p -r1.15 doublest.c
--- doublest.c 8 Jun 2003 18:27:13 -0000 1.15
+++ doublest.c 10 Jun 2003 18:44:30 -0000
@@ -404,7 +404,15 @@ convert_doublest_to_floatformat (CONST s
{
mant_long <<= 1;
mant_long &= 0xffffffffL;
- mant_bits -= 1;
+ /* If we are processing the top 32 mantissa bits of a doublest
+ so as to convert to a float value with implied integer bit,
+ we will only be putting 31 of those 32 bits into the
+ final value due to the discarding of the top bit. In the
+ case of a small float value where the number of mantissa
+ bits is less than 32, discarding the top bit does not alter
+ the number of bits we will be adding to the result. */
+ if (mant_bits == 32)
+ mant_bits -= 1;
}
if (mant_bits < 32)
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: RFA: patch to convert_doublest_to_floatformat in doublest.c
2003-06-10 19:16 RFA: patch to convert_doublest_to_floatformat in doublest.c J. Johnston
@ 2003-06-11 21:20 ` Kevin Buettner
2003-06-11 21:25 ` J. Johnston
2003-06-11 22:15 ` Kevin Buettner
1 sibling, 1 reply; 5+ messages in thread
From: Kevin Buettner @ 2003-06-11 21:20 UTC (permalink / raw)
To: J. Johnston, gdb-patches
On Jun 10, 3:16pm, J. Johnston wrote:
> The old algorithm is correct for floating values whereby there are
> 32 or more mantissa bits. In such a case, we only can put 31 bits
> into the result. A simple test was added. The patch has been
> tested on the ia64 and x86.
I'm wondering about the test that you added. You say that the old
algorithm was correct for 32 or *more* mantissa bits. Yet the test
you added is as follows:
> + if (mant_bits == 32)
I'm wondering if this should instead be:
if (mant_bits >= 32)
?
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: RFA: patch to convert_doublest_to_floatformat in doublest.c
2003-06-11 21:20 ` Kevin Buettner
@ 2003-06-11 21:25 ` J. Johnston
0 siblings, 0 replies; 5+ messages in thread
From: J. Johnston @ 2003-06-11 21:25 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches
Kevin Buettner wrote:
> On Jun 10, 3:16pm, J. Johnston wrote:
>
>
>>The old algorithm is correct for floating values whereby there are
>>32 or more mantissa bits. In such a case, we only can put 31 bits
>>into the result. A simple test was added. The patch has been
>>tested on the ia64 and x86.
>
>
> I'm wondering about the test that you added. You say that the old
> algorithm was correct for 32 or *more* mantissa bits. Yet the test
> you added is as follows:
>
>
>>+ if (mant_bits == 32)
>
>
> I'm wondering if this should instead be:
>
> if (mant_bits >= 32)
>
> ?
>
> Kevin
>
No, it is ok. The algorithm only processes 32 bits at a time. If
you look earlier, you will see:
mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
-- Jeff J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: RFA: patch to convert_doublest_to_floatformat in doublest.c
2003-06-10 19:16 RFA: patch to convert_doublest_to_floatformat in doublest.c J. Johnston
2003-06-11 21:20 ` Kevin Buettner
@ 2003-06-11 22:15 ` Kevin Buettner
2003-06-11 23:35 ` J. Johnston
1 sibling, 1 reply; 5+ messages in thread
From: Kevin Buettner @ 2003-06-11 22:15 UTC (permalink / raw)
To: J. Johnston, gdb-patches
On Jun 10, 3:16pm, J. Johnston wrote:
> * doublest.c (convert_doublest_to_floatformat): When dealing with the implied
> integer bit, only alter mant_bits if we are processing a full 32 bits of
> mantissa.
>
> Index: doublest.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/doublest.c,v
> retrieving revision 1.15
> diff -u -p -r1.15 doublest.c
> --- doublest.c 8 Jun 2003 18:27:13 -0000 1.15
> +++ doublest.c 10 Jun 2003 18:44:30 -0000
> @@ -404,7 +404,15 @@ convert_doublest_to_floatformat (CONST s
> {
> mant_long <<= 1;
> mant_long &= 0xffffffffL;
> - mant_bits -= 1;
> + /* If we are processing the top 32 mantissa bits of a doublest
> + so as to convert to a float value with implied integer bit,
> + we will only be putting 31 of those 32 bits into the
> + final value due to the discarding of the top bit. In the
> + case of a small float value where the number of mantissa
> + bits is less than 32, discarding the top bit does not alter
> + the number of bits we will be adding to the result. */
> + if (mant_bits == 32)
> + mant_bits -= 1;
> }
>
> if (mant_bits < 32)
Okay.
Kevin
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: RFA: patch to convert_doublest_to_floatformat in doublest.c
2003-06-11 22:15 ` Kevin Buettner
@ 2003-06-11 23:35 ` J. Johnston
0 siblings, 0 replies; 5+ messages in thread
From: J. Johnston @ 2003-06-11 23:35 UTC (permalink / raw)
To: Kevin Buettner; +Cc: gdb-patches
Patch checked in. Thanks.
-- Jeff J.
Kevin Buettner wrote:
> On Jun 10, 3:16pm, J. Johnston wrote:
>
>
>> * doublest.c (convert_doublest_to_floatformat): When dealing with the implied
>> integer bit, only alter mant_bits if we are processing a full 32 bits of
>> mantissa.
>>
>>Index: doublest.c
>>===================================================================
>>RCS file: /cvs/src/src/gdb/doublest.c,v
>>retrieving revision 1.15
>>diff -u -p -r1.15 doublest.c
>>--- doublest.c 8 Jun 2003 18:27:13 -0000 1.15
>>+++ doublest.c 10 Jun 2003 18:44:30 -0000
>>@@ -404,7 +404,15 @@ convert_doublest_to_floatformat (CONST s
>> {
>> mant_long <<= 1;
>> mant_long &= 0xffffffffL;
>>- mant_bits -= 1;
>>+ /* If we are processing the top 32 mantissa bits of a doublest
>>+ so as to convert to a float value with implied integer bit,
>>+ we will only be putting 31 of those 32 bits into the
>>+ final value due to the discarding of the top bit. In the
>>+ case of a small float value where the number of mantissa
>>+ bits is less than 32, discarding the top bit does not alter
>>+ the number of bits we will be adding to the result. */
>>+ if (mant_bits == 32)
>>+ mant_bits -= 1;
>> }
>>
>> if (mant_bits < 32)
>
>
> Okay.
>
> Kevin
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2003-06-11 23:35 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-10 19:16 RFA: patch to convert_doublest_to_floatformat in doublest.c J. Johnston
2003-06-11 21:20 ` Kevin Buettner
2003-06-11 21:25 ` J. Johnston
2003-06-11 22:15 ` Kevin Buettner
2003-06-11 23:35 ` J. Johnston
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox