The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,811 other followers

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  NaN).

At first – in the Delphi 8 (Octane) era of which few people want to be reminded off – it was the undocumented counterpart of the 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):

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 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:

  1. In the past you could only set the exception mask as part of the full control word using Set8087CW, nowadays you can use SetExceptionMask.
  2. Next to a precision mask, there are five exception masks you can set, see for instance this table from the 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

One Response to “Delphi history – on the FINITEFLOAT compiler option that has no one-character shortcut”

  1. 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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: