[m-rev.] for review: fix float_to_string so that roundtripping works

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Nov 21 02:35:31 AEDT 2002


On 20-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> On Wed, Nov 20, 2002 at 03:04:22PM +0100, Peter Ross wrote:
> > +#ifdef MR_USE_SINGLE_PREC_FLOAT
> > +	#define MIN_PRECISION	7
> > +	const char *format = ""%f"";
> > +#else
> > +	#define MIN_PRECISION	15
> > +	const char *format = ""%lf"";
> > +#endif
> > +	int i = MIN_PRECISION;
...
> > +	while (round != Flt) {
> 
> This test has been changed to (round != Flt && i < 2) to avoid an infinite
> loop.

`i' will never be less than 2, unless it wraps around,
since it starts off at 7 or 15 at is only ever incremented,
not decremented.

BTW, the use of MIN_PRECISION here is another namespace violation
like the one I pointed out earlier.  It could clash with someone
else's use of that name.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list