[m-rev.] diff: fix output precision of deconstruct

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Nov 30 01:05:41 AEDT 2002


On 29-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> This is one of many changes which fix problems with outputting floats.
> None of these changes are on the release branch, do we want to add all
> the changes to the release branch as well?

I think it is too late for changes like that now.
They are too likely to be destabilizing.
So I suggest we save these for 0.11.1 or 0.12.

I really want to release 0.11 soon.  I want the released version to
be passing all or very nearly all of its test cases on most platforms.
If we keep on making changes, this will never happen.  So at this point
I think bug fixes should go on the release branch only if they

	- address failures in the 0.11 test suite
or
	- are release-critical (e.g. those that break the build;
	  those that cause problems with installation or with
	  binary distributions; security holes;
	  or other serious problems like that)
or
	- are very simple (ideally a one-line change to a single file),
	  and are not likely to have much impact elsewhere,
	  and are important enough and low risk enough to be worth
	  risking delaying the release (e.g. the C# interface \n bug)

> +void
> +MR_sprintf_float(char *buf, MR_Float f)
> +{
> +	MR_Float round = 0.0;
> +	int 	 i = MR_FLT_MIN_PRECISION;
> +
> +	/*
> +	** Print the float at increasing precisions until the float
> +	** is round-trippable.
> +	*/
> +	do {
> +		sprintf(buf, "%#.*g", i, f);
> +		if (i >= MR_FLT_MAX_PRECISION) {
> +			/*
> +			** This should be sufficient precision to
> +			** round-trip any value.  Don't bother checking
> +			** whether it can actually be round-tripped,
> +			** since if it can't, this is a bug in the C
> +			** implementation.
> +			*/
> +			break;
> +		}
> +		sscanf(buf, MR_FLT_FMT, &round);
> +		i++;
> +	} while (round != f);
> +
> +    return;
> +}

The final "return;" doesn't really add anything to the readability
of this routine, IMHO.

While you're at it, s/i/prec/g would probably improve readability a little.

-- 
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