I am not sure what the return code from val() is supposed to be. If I try to convert a number in val() that is too large for a floating point Double, say 1e310, I do not get an error and the return code is 0. The converted Double is '+inf' in the debugger. Seems reasonable to convert to positive infinite for an overflow but it seems like throwing an overflow exception would be better. The return code from val() does not appear to have an expected meaning or value. Maybe the {$R+} directive would help? The trunc() function does not like the value 1e42, of course, because it is too large for an int64 value, that is, larger than 9,223,372,036,854,775,807. The trunc() function throws an exception, as expected, when the value is too large. Perhaps it would be better to check in your code to see if the converted real number is less than the maximum for an int64.
Tested on Lazarus version 4.0; FPC version 3.2.2; win64.