%mathpiper,def="FloatIsInt"

/// TODO FIXME document this: FloatIsInt returns True if the argument is integer after removing potential trailing
/// zeroes after the decimal point
// but in fact this should be a call to BigNumber::IsIntValue()
FloatIsInt(_x) <--
   [
     x:=N(Eval(x));
     Local(prec,result,n);
     Bind(prec,BuiltinPrecisionGet());
     If(IsZero(x),Bind(n,2),
     If(x>0,
       Bind(n,2+FloorN(N(FastLog(x)/FastLog(10)))),
       Bind(n,2+FloorN(N(FastLog(-x)/FastLog(10))))
       ));
     BuiltinPrecisionSet(n+prec);
     Bind(result,IsZero(RoundTo(x-Floor(x),prec)) Or IsZero(RoundTo(x-Ceil(x),prec)));
     BuiltinPrecisionSet(prec);
     result;
   ];
//  

%/mathpiper