float to bfloat



If you can set the epsilon, then you could set it to less than 10^(-18)
and get the behavior you want, assuming it is a relative error, and get
the behavior you want.  The argument against it is, I think, this:

bfloat(0.1)  is a float-to-bigfloat conversion.   Do you want it to
come out as the bigfloat version of 1/10, 0.1000000000000000000,
actually... 1.0b-1  or do you want it to come
out as the bigfloat version of .99999994039535522...
The first of these requires a lot less explanation to most people.
In either case a careful explanation should be available so the
behavior is not viewed as a bug.

Since the commercial macsyma goes towards the .9999999... perhaps
they have thought it through and written down explanations? I haven't
looked in their (online) manual.



RJF



Raymond Toy wrote:

>>>>>>"Richard" == Richard Fateman <fateman@cs.berkeley.edu> writes:
>>>>>>            
>>>>>>
>
>    Richard> The point of this seems to be that a float can be converted into an
>    Richard> exact equivalent rational number, like 0.333333333334  can be converted
>    Richard> to 3333333333334/100000000000    or whatever that is reduced to
>    Richard> lowest terms and typed with the right number of 3333... .
>    Richard> OR one could observe that a very compact rational number, 1/3, is quite
>    Richard> close to that float value, and decide to rationalize it to 1/3, even though
>    Richard> it isn't the absolute closest.
>
>    Richard> Which would you like?  My recollection is that there is some "epsilon" in
>    Richard> the rationalize code in maxima.  If you set it to less than
>    Richard> one-unit-in-the-last-place
>    Richard> (ULP) of the single or double float representation, then you get the version
>    Richard> that Stavros wants.  If you set it to something less, (like 2 ULP)
>    Richard> then you would
>    Richard> get  1/3 --> floats to  0.33333334  --> bfloats to
>    Richard> 0.3333333333333333333333333333
>    Richard> instead of                          -->
>    Richard> 0.3333333434534534436426908
>
>    Richard> I would prefer having that epsilon around if possible.
>
>Yes there is some maxima rationalize function with an epsilon
>somewhere.
>
>I think bfloat(float) should just convert without rationalization.
>Then if you really want to rationalize, you can
>bfloat(rationalize(float)) if you want.  Current behavior won't really
>allow that.
>
>I'm assuming that there is a rationalize function available to the
>user.  If not we should add one.
>
>Ray
>
>_______________________________________________
>Maxima mailing list
>Maxima@www.math.utexas.edu
>http://www.math.utexas.edu/mailman/listinfo/maxima
>  
>