Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6774007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:44:08+00:00 2026-05-26T15:44:08+00:00

My app is written in Delphi5. I am using madExcept to track down bugs.

  • 0

My app is written in Delphi5. I am using madExcept to track down bugs. I tracked down a “Floating point dvision by zero” exception, where it shouldn’t be. The code segment, where it is raised, goes as followed:

val:=100*Power(1.25,c);

where ‘c’ actually always has the value ‘1’.

The stack trace of the log:

main thread ($338f8):
00403504 +010 MyApp.exe   System   1970  +5 @FRAC
00479148 +058 MyApp.exe   Math              Power
007ae8a6 +262 MyApp.exe   MyClass  1962 +36 TMyClass.FormMouseWheel

I had another exception at one point, where a division did take place, however the divisor was a variable, which also had the value ‘1’ when the exception occured. That i was able to debug and reproduce.

My question: what am i missing? Are there some false positives about floating point division that i am not aware of?

Furthermore: I am not using any C++ DLLs at the exception points as they tend to handle FP divisions differently (returning NaN or +/-INF rather than raising an exception).

Any pointers appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:44:09+00:00Added an answer on May 26, 2026 at 3:44 pm

    I just tried the following code:

    procedure TTTest.FormCreate(Sender: TObject);
    var v: extended;
        one: extended;
    begin
      one := 1.0;
      v := 100*Power(1.25,one);
    end;
    

    It just compiles and runs as expected in Delphi 5.

    My guess is that the division per zero flag may be set outside your code (even if you do not link to C++ code, calling Direct X or such may have the same effect), but raised later, in _Frac.

    The only call to Frac in the standard implementation of Power() is to test Frac(Exponent) = 0.0.

    There was a modification in the implementation of Frac between Delphi 5 and Delphi 6.

    Here is the Delphi 5 version:

    procedure       _FRAC;
    asm
        FLD     ST(0)
        SUB     ESP,4
        FSTCW   [ESP]
        FWAIT
        FLDCW   cwChop
        FRNDINT
        FWAIT
        FLDCW   [ESP]
        ADD     ESP,4
        FSUB
    end;
    

    Here is the Delphi 6 version:

    procedure       _FRAC;
    asm
        FLD     ST(0)
        SUB     ESP,4
        FNSTCW  [ESP].Word     // save
        FNSTCW  [ESP+2].Word   // scratch
        FWAIT
        OR      [ESP+2].Word, $0F00  // trunc toward zero, full precision
        FLDCW   [ESP+2].Word
        FRNDINT
        FWAIT
        FLDCW   [ESP].Word
        ADD     ESP,4
        FSUB
    end;
    

    From the above code, you’ll find out that the following commands caused the delayed exceptions to be raised before Delphi 6 was released: Trunc, Frac, Ceil.

    So I guess you faced an issue with Delphi 5, which has been fixed with Delphi 6. You may have to use your own version of Power, like this one:

    function Power(Base, Exponent: Extended): Extended;
    begin
      if Exponent = 0.0 then
        Result := 1.0               { n**0 = 1 }
      else if (Base = 0.0) and (Exponent > 0.0) then
        Result := 0.0               { 0**n = 0, n > 0 }
      else
        Result := Exp(Exponent * Ln(Base))
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an existing app written in PHP (using Kohana framework) and I want
I have mobile app written in HTML5 using PhoneGap. Some parts of the app
I have an app written in Delphi 7, which using Firebird 2.1 db and
I have test app written on ruby, using Sinatra+Sequel. config.ru: require './main' run Sinatra::Application
I'm working on a network app written in Java, using ObjectOutputStream and ObjectInputStream on
I have a WinForms app written in C# with .NET 3.5. It runs a
I have an app written in C# that lies on a network share. When
I have a GUI app written in C++/CLI which has a load of configurable
I have an MDI app written in Qt. Some of the subwindows include QGLWidget
I have a Django app written in Python 2.5 and I plan to upgrade

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.