[fpc-pascal] Loss of precision when using math.Max()

Martok listbox at martoks-place.de
Tue Jul 10 19:35:35 CEST 2018


>> I seem to remember that this was once documented somewhere for Delphi. Can't
>> seem to find it though, so maybe it was a 3rd-party book? There is  
>> no hint of it
>> in the FPC documentation, anyway.
> As already noted, it is not necessary in DelphiAh sorry, I was wrong: misremembered Integer const evaluation, where you should
cast the first part of the expression to Int64 if you want your expression to be
evaluated as that instead of Integer. Completely different issue.


The fix for #25121 doesn't seem like the best solution. The reported issue was
with explicit casts, I think the truncation should rather be in
ttypeconvnode.{typecheck_int_to_real, typecheck_real_to_real,
typecheck_real_to_currency} ?

That would give bestreal-precision back to const evaluation *unless* the
programmer explicitly casts to a lower precision? During Codegen, casting down
happens anyway because of the storage requirements.

-- 
Regards,
Martok





More information about the fpc-pascal mailing list