🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #570

Bug fix for gas 1.34 atof

#570
From: Georg Feil
Date: Fri, 01 Dec 1989 00:12
52 lines
2279 bytes
Here is the fix for a bug in gas 1.34 that I reported several weeks ago
but was too lazy to go after. As I suspected at that time, it turned out to
be a nasty one (~ 6 hour bug hunt).

The problem involves the ascii to floating-point conversion routines
atof-generic.c and flonum-mult.c when given numbers with excess trailing
zeroes. Here is a test file that demonstrates the bug:

--------------------- bad.s --------------------
.data
        .double 0r4.50359962737049600000e+15
------------------------------------------------


Here is a similar file that assembles correctly:

--------------------- good.s --------------------
.data
        .double 0r4.503599627370496e+15
------------------------------------------------

Compare the binary output from assembling these two input files, and you
should find that it differs. Closer inspection will show loss of precision
in the 'bad.s' case.

There are two patches, as follows:

-------------------- diff old.flonum-mult.c flonum-mult.c -----------
146c146
<       if (significant)
---
>       if (significant || P < 0)
---------------------------------------------------------------------


------------------- diff old.atof-generic.c atof-generic.c ---------
270,271c270,271
<                  )            /* Number of destination littlenums. */
<       + 2;                    /* + 2 :: guard bits :: excess precision */
---
>                  );           /* Number of destination littlenums. Should
>                               /* already include guard bits (2 littlenums) */
---------------------------------------------------------------------


Georg.
-- 
Georg Feil                                            "The roof is leaking
ghfeil@white.toronto.edu                               and the wind is howling"
...if that doesn't work try one of:
{uunet,pyramid,watmath,utzoo}!utcsri!white!ghfeil
ghfeil%white.toronto.edu@relay.cs.net     (ARPA)
Technical Details
Message-ID: <89Nov30.191130est.27214@snow.white.toronto.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!daemon

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!daemon
Newsgroups: gnu.utils.bug
From: ghfeil@white.toronto.edu (Georg Feil)
Subject: Bug fix for gas 1.34 atof
Message-ID: <89Nov30.191130est.27214@snow.white.toronto.edu>
Sender: <daemon>
Organization: University of Toronto, CSRI
Date: 1 Dec 89 00:12:50 GMT