I wrote:
Emil Jerabek wrote:
It solves the problem in AddHeapRange, but seems to introduce another failure.
TEST bprealtest.pas: ./a.out: error in exponentiation (Numerical result out of range) (error #700 at 804b08a)
Yes, I get this as well. The problem is this line:
x.r := (Random + 1e-6) * Exp (Random (86) - 43);
Of course, we could work-around it in this example by an explicit cast or conversion, and perhaps that's actually what we *should* do, given that `Random' is of type `LongestCard'. So this failure is easy to fix, I'm just not certain if there are more serious problems like this ...
Finally, one could think of changing the result type of `Random'.
However, we could have different versions for `LongestCard' and plain `Cardinal', and choose the one to use based on the argument type. As we do this for other built-ins (e.g. `Write'), and it would fix this problem, and would probably even be somewhat more efficient, perhaps we should do this ...
However, it wouldn't solve the problem on 64 bit platforms until we have 128 bit types, and it would create additional complications WRT RandIntPtr.
So what I do now instead is to simply convert the result to LongestInt if the argument is known (at compile time) to fit (because the result cannot be larger than the argument). I think this should close the issue WRT `Random' and thus `bprealtest.pas'. One can still get larger random ranges (up to `High (LongestCard)'), and in this case, one must obviously be prepared to handle the large range in one's code.
Frank