Forum > Android

Disable softfloat FPU exceptions

(1/1)

meanderix:
I was getting FPU underflow exceptions when using the software emulated floats (I did not get this with an ordinary FPU.)

However, I figured out that everything worked fine if I added the following line when starting my app:

--- Code: ---  softfloat_exception_mask := $ff;        // from Math unit
--- End code ---

Reposting here in case anyone else should come across this problem.

meanderix:
Ok, I found the source of my floating point errors:

--- Code: ---  function power(base,exponent : float) : float;
  begin
    if Exponent=0.0 then
      result:=1.0
    else if (base=0.0) and (exponent>0.0) then
      result:=0.0
    else if (abs(exponent)<=maxint) and (frac(exponent)=0.0) then
      result:=intpower(base,trunc(exponent))
    else if base>0.0 then
      result:=exp(exponent * ln (base))
    else
      InvalidArgument;
  end;
--- End code ---

This function is not working correctly, but it works fine if I change it like this:

--- Code: ---  function power(base,exponent : float) : float;
  begin
    if Exponent=0.0 then
      result:=1.0
    else if (base=0.0) and (exponent>0.0) then
      result:=0.0
    else if base>0.0 then
      result:=exp(exponent * ln (base))
    else
      InvalidArgument;
  end;
--- End code ---

Should this be reported?

Navigation

[0] Message Index

Go to full version