Question: How to convert a hardware float to software float?

How do I convert a hardware float to a software float? I have a procedure that is passed floats as arguments. They could be hardware or software floats. I need to set an attribute on these floats (with setattribute). Trying to use setattribute on a hardware float produces utterly bizarre results, although, strangely, not an error. But I'd be happy converting them to software floats and then setting the attribute. I tried (separately)

UseHardwareFloats:= false;

convert(x, float, 16);

SFloat(op(x));

And, FWIW, here's the procedure, although I doubt that it'll provide any more useful information than I've already given. Note that in this procedure I've redefined log to be the base-10 logarithm. (Not that that makes the slightest difference wrt my Question.)

LogView:= proc(viewspec::{range, identical(DEFAULT)}, Range::range)
local aV, bV, aP, bP, aL, bL;
     (aP,bP):= op(map(x-> 10^x, Range)); # The actual range of the ORIGINAL plot structure
     if viewspec = 'DEFAULT' then
          setattribute(op(1,Range), aP) .. setattribute(op(2,Range), bP)
     else
          (aV,bV):= op(viewspec); #The user-specified view in the pre-log units
          if bV <= 0 then error "upper view limit must be positive; received %1.", bV fi;
          (aL,bL):= op(Range); #Actual range of the log plot structure
          setattribute(`if`(aV >= aP, log(aV), aL - (aP-aV)/(min(bP,bV)-aP)*(log(min(bP,bV))-aL)), aV) 

          .. setattribute(`if`(bV <= bP, log(bV), bL + (bV-bP)/(bP-max(aP,aV))*(bL-log(max(aP,aV)))), bV) 

     end if
end proc;

In the specific use instance that I'm dealing with, the first parameter, viewspec, is DEFAULT, and the second, Range, is HFloat(-43.42...)..HFloat(43.42...).

I think the ideal solution would be to use parameter coercion to convert the arguments.

Please Wait...