[m-rev.] for review: mercury implementation of float_to_string

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Nov 26 00:36:14 AEDT 2002


On 25-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> 
> +++ string.m	25 Nov 2002 12:12:51 -0000
> @@ -97,8 +97,11 @@
>  :- mode string__float_to_string(in, uo) is det.
>  %	Convert an float to a string.
>  %	The resulting float will be in the form that it was printed using
> -%	the format string "%#.<prec>g" where <prec> is the required precision
> -%	needed to represent the string.
> +%	the format string "%#.<prec>g" where <prec> is in the range p to (p+2)
> +%	where p = floor(mantissa_digits * log2(base_radix) / log2(10)) and
> +%	the precision is sufficient to allow a succesful decimal -> binary
> +%	conversion of the float.

This specification could be overly constraining on future implementations.
For example, we might want to change this to a Java-like output in future.
Therefore, I suggest adding "In the current implementation, " before
"the resulting float ...". 

s/succesful/successful/

>  :- pred string__first_char(string, char, string).
>  :- mode string__first_char(in, in, in) is semidet.	% implied
> @@ -1857,24 +1860,31 @@
>  		( string__to_float(Tmp, Float) ->
>  			String = Tmp
>  		;
> -			String = float_to_string_2(Prec + 1, Float)
> +			String = string__float_to_string_2(Prec + 1, Float)
>  		)
>  	).
>  
> -	% We assume that on non-C backends that we are using double
> -	% precision floats.
> +	% XXX For efficency reasons we assume that on non-C backends that we

s/efficency/efficiency/

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