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 50279
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T16:34:06+00:00 2026-05-10T16:34:06+00:00

AFAIK, Currency type in Delphi Win32 depends on the processor floating point precision. Because

  • 0

AFAIK, Currency type in Delphi Win32 depends on the processor floating point precision. Because of this I’m having rounding problems when comparing two Currency values, returning different results depending on the machine.

For now I’m using the SameValue function passing a Epsilon parameter = 0.009, because I only need 2 decimal digits precision.

Is there any better way to avoid this problem?

  • 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. 2026-05-10T16:34:07+00:00Added an answer on May 10, 2026 at 4:34 pm

    The Currency type in Delphi is a 64-bit integer scaled by 1/10,000; in other words, its smallest increment is equivalent to 0.0001. It is not susceptible to precision issues in the same way that floating point code is.

    However, if you are multiplying your Currency numbers by floating-point types, or dividing your Currency values, the rounding does need to be worked out one way or the other. The FPU controls this mechanism (it’s called the ‘control word’). The Math unit contains some procedures which control this mechanism: SetRoundMode in particular. You can see the effects in this program:

    {$APPTYPE CONSOLE}  uses Math;  var   x: Currency;   y: Currency; begin   SetRoundMode(rmTruncate);   x := 1;   x := x / 6;   SetRoundMode(rmNearest);   y := 1;   y := y / 6;   Writeln(x = y); // false   Writeln(x - y); // 0.0001; i.e. 0.1666 vs 0.1667 end. 

    It is possible that a third-party library you are using is setting the control word to a different value. You may want to set the control word (i.e. rounding mode) explicitly at the starting point of your important calculations.

    Also, if your calculations ever transfer into plain floating point and then back into Currency, all bets are off – too hard to audit. Make sure all your calculations are in Currency.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 67k
  • Answers 68k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer SQuirreL, written in java, will work with any RDBMS for… May 11, 2026 at 12:03 pm
  • added an answer In normal mode, use the pipe character: 25| will move… May 11, 2026 at 12:03 pm
  • added an answer OCCI Environment lets you define your own memory management functions… May 11, 2026 at 12:03 pm

Related Questions

AFAIK, Currency type in Delphi Win32 depends on the processor floating point precision. Because
AFAIK one of the objectives of Stack Overflow is to make sure anyone can
AFAIK ROWID in Oracle represents physical location of a record in appropriate datafile. In

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.