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

  • SEARCH
  • Home
  • 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 9171429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:09:42+00:00 2026-06-17T16:09:42+00:00

When compiled with Delphi 2009 and run, this console application writes strange. The values

  • 0

When compiled with Delphi 2009 and run, this console application writes “strange”.
The values on both sides of the “less than” operator are equal, but the code behaves as if they are not equal. What can I do to avoid this problem?

program Project5;

{$APPTYPE CONSOLE}

var
  C: Currency;
begin
  C := 1.32;

  if C < 1.32 then
  begin
    WriteLn('strange');
  end;

  ReadLn;
end.

p.s. code works fine with other values.

This answer by Barry Kelly explains that the Currency type “is not susceptible to precision issues in the same way that floating point code is.”

  • 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-06-17T16:09:43+00:00Added an answer on June 17, 2026 at 4:09 pm

    As fas as hard casting like Currency(1.32) is not possible, you could use the following for explicit casting

    Function ToCurrency(d:Double):Currency;
        begin
           Result := d;
        end;
    
    procedure TForm1.Button1Click(Sender: TObject);
    
    var
      C: Currency;
    
    begin
      C := 1.32;
      if C < ToCurrency(1.32) then
      begin
        Writeln ('strange');
      end;
    end;
    

    another way could by forcing the usage of curreny by usage of a const or variable

    const
      comp:Currency=1.32;
    var
      C: Currency;
    begin
      C := 1.32;
      if C < comp then
      begin
        writeln ('strange');
      end;
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When i Run this code in a 32 bits delphi application the connection to
I have upgraded to Delphi XE from 2009 and am experiencing a strange issue.
Why will this not compile in Delphi 2009? unit VistaFolders; interface uses Windows, ShellAPI,
I converting a lecacy app from Delphi 7 to Delphi 2009. I got this
I'm checking out the Delphi 2009 Trial, but run into problems with the generics
I'm debugging a legacy Delphi service application (it is old but compiled with Delphi
I compiled python 2.6.4 for centos 5.3 and find this issue that os.path.getmtime() or
I release a single executable (.EXE) for a desktop program using Delphi 2009. I
I'm using Delphi 2009. My program has been compiling and running fine. I use
When compiling code without initializing a THandle the Delphi 2009 compiler gives a warning

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.