Maxima currently gives warnings for certain kinds of approximate
numerical conversions but not others.
It gives warnings for:
rat(0.5) -- controlled by ratprint
rat(0.5b0) -- controlled by ratprint
bfloat(0.5) -- controlled by float2bf
The warnings are presumably to let the user know that precision is being
lost. In the rat case, they are also presumably to let the user know
that the rat package is converting all floats to rats.
But the conversion should be exact for bfloat of float when fpprec >= 16
(the default); for rat of float/bfloat when ratepsilon = 0; and for
float/bfloat of a/2^n for sufficiently small n (though there may be
bugs). In those cases, perhaps the rationale is to warn that the
calculation will continue with spurious precision.
But in other cases, Maxima gives a warning for neither loss of precision
nor gain of spurious precision:
float(0.5b0) -- loss or gain, depending on fpprec
float(1/3) -- loss
bfloat(1/3) -- loss
loprec3: bfloat(1/3),fpprec:5 0.33333
hiprec3: bfloat(1/3),fpprec:50 0.333333...3333
fpprec: 16 (default)
bfloat(lowprec3) -- gain
bfloat(hiprec3) -- loss
bfloat(10^100) -- loss
We should put some order into this situation. I do not think we need a
separate switch for each case (rat2bf, bf2float, etc.). Instead, I'd
propose something like
approximate_conversion_warn
with values of: true (warn always), false (warn never), loss (warn only
on loss of precision). And the individual conversion routines should
only warn when there is actual loss of precision: float(5/32) doesn't
count....
I would make the default be warn never (false). On the other hand, I
would give the user one warning per call to Rat() that converts floats,
along the lines of:
Warning: Rat converts all floating-point numbers to rationals unless
keepfloat=true.
And as we've discussed before, I'd make the default value of ratepsilon
be something like double-float-epsilon * 10 at most.
Comments?
-s