The infinite test/function is only available for single, double and extended. But not for real type.
From the documentation:
https://www.freepascal.org/docs-html/ref/refsu5.htmlThe Real native type is processor dependent, but it is either a Single or a Double.
So you can just call IsInfinity, and it will either call the Single or Double variant, depending on your platform.
I am converting big integers to and from real types, in a platform independent way that will work in any environment. I need reliable trapping of overflow erors, because the big integer values can far exceed the capacity of any real type.
I don't think that you are actually talking about overflow here, because Double, the largest Float type available on all systems (there are 80bit Extended, but they are platform dependent) has a maximum value of 1.7*10^308 meaning a value with 308 digits.
The problem you probably have is rather than that imprecision, because as soon as your number has more bits (which are not a 0 tail) than the float mantissa size (23 bit for single, 52 bit for double), you will lose precision on conversion.
But this is easy to figure out:
function CheckIfBigintFitsReal(AInt: TBigInteger): Boolean; inline;
const
{ Either 24 if Real = Single, or 53 if Real = Double (0 if neither) }
RealBits = 24*(SizeOf(Real)=SizeOf(Single)) + 53*(SizeOf(Real)=SizeOf(Double));
begin
Result:=AInt>=(1 shl RealBits);
end;
But my question is, if you are dealing with bigintegers, why do you want to convert them into floats to begin with? Floats aren't really good if you need precise computations
The Free Pascal documentation states that the real type is "platform dependent", so that might be part of the problem.
Yes, Real is an relic you shouldn't use it anymore. Use Double or Extended instead.