Delphi history – on the FINITEFLOAT compiler option that has no one-character shortcut
Posted by jpluimers on 2016/12/14
Back in the .NET days, Delphi had an FINITEFLOAT
compile option that came without a single-character shortcut.
It was about the handling of infinite float and other special float values in cases like overflow and underflow (including +Inf, -Inf and [Wayback] NaN).
At first – in the [Wayback] Delphi 8 (Octane) era of which few people want to be reminded off – it was the [Wayback] undocumented counterpart of the [Wayback] 8087 exception mask in x86 mode. Hallvard Vassbotn wrote an article about it and Chee Wee Chua documented it before it got documented in Delphi 2009 (that coincidentally dropped .NET support in the compiler – go figure):
- [Wayback] Hallvard’s Blog: DN4DP#16: .NET only: Floating-point semantics
- [Wayback] Undocumented Delphi 8 compiler directive FINITEFLOAT – Chee Wee’s blog: IT solutions for Singapore and companies worldwide
- [Wayback] Floating Point Exception Checking (Delphi)
$FINITEFLOAT
Whereas the native Delphi compilers had exceptions turned on, Microsoft compilers (including .NET) had them turned off, hence the compiler option.
Like most new Delphi features in this century, FINITEFLOAT
didn’t come without quirks. Often these are fleshed out in 2-3 product releases, but this one wasn’t:
The FINITEFLOAT
compile option didn’t have a single-character shortcut. This made it impossible to use the {$IFOPT ...}
construct as IFOPT
only works for single-character compiler options.
Which means you get questions like [Wayback] Why doesn’t {$ifopt FINITEFLOAT ON} compile? – Stack Overflow (I actually got into writing this article because I found a {$DEFINE FINFINITEFLOAT_ENABLED}
in some pretty old code) and compiler enhancement requests like [WayBack] QualityCentral – Please enhance the IFOPT directive for long switch names. It’s easier to read (which will likely never bee fixed).
For completeness some more information about exception masks in the native compiler:
- In the past you could only set the exception mask as part of the full control word using [Wayback] Set8087CW, nowadays you can use [Wayback] SetExceptionMask.
- Next to a precision mask, there are five exception masks you can set, see for instance this table from the [Wayback] Simply FPU Chap.1 Control Word section:
PM (bit 5) or Precision Mask
UM (bit 4) or Underflow Mask
OM (bit 3) or Overflow Mask
ZM (bit 2) or Zero divide Mask
DM (bit 1) or Denormalized operand Mask
IM (bit 0) or Invalid operation Mask
–jeroen
jpluimers said
Via https://plus.google.com/u/0/+JeroenPluimers/posts/HS8eqnmepvY
David Berneda: Last time I checked 1/0 in Firemonkey, no exception. It seems fmx has some unit (D2D I think) that (accidentally?) calls SetExceptionMask to disable them