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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T20:59:29+00:00 2026-05-10T20:59:29+00:00

So far I’ve seen many posts dealing with equality of floating point numbers. The

  • 0

So far I’ve seen many posts dealing with equality of floating point numbers. The standard answer to a question like ‘how should we decide if x and y are equal?’ is

abs(x - y) < epsilon 

where epsilon is a fixed, small constant. This is because the ‘operands’ x and y are often the results of some computation where a rounding error is involved, hence the standard equality operator == is not what we mean, and what we should really ask is whether x and y are close, not equal.

Now, I feel that if x is ‘almost equal’ to y, then also x*10^20 should be ‘almost equal’ to y*10^20, in the sense that the relative error should be the same (but ‘relative’ to what?). But with these big numbers, the above test would fail, i.e. that solution does not ‘scale’.

How would you deal with this issue? Should we rescale the numbers or rescale epsilon? How? (Or is my intuition wrong?)

Here is a related question, but I don’t like its accepted answer, for the reinterpret_cast thing seems a bit tricky to me, I don’t understand what’s going on. Please try to provide a simple test.

  • 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-10T20:59:29+00:00Added an answer on May 10, 2026 at 8:59 pm

    It all depends on the specific problem domain. Yes, using relative error will be more correct in the general case, but it can be significantly less efficient since it involves an extra floating-point division. If you know the approximate scale of the numbers in your problem, using an absolute error is acceptable.

    This page outlines a number of techniques for comparing floats. It also goes over a number of important issues, such as those with subnormals, infinities, and NaNs. It’s a great read, I highly recommend reading it all the way through.

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

Sidebar

Ask A Question

Stats

  • Questions 59k
  • Answers 59k
  • 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 Quite easy. What you need to do is create an… May 11, 2026 at 8:56 am
  • added an answer The best way to serve content to a mobile user… May 11, 2026 at 8:56 am
  • added an answer I think you're missing something about disposing your objects like… May 11, 2026 at 8:56 am

Related Questions

So far I have encountered adjacency list, nested sets and nested intervals as models
So far, I've only been passing javascript strings to my web methods, which get
So far I've been using public void run() {} methods to execute my code
So far I've seen many posts dealing with equality of floating point numbers. The
So far I've read some blog articles about cloud computing and services for hosting
So far i have got the code below which works lovely when trying an
So far, no Delphi version supports SOAP 1.2 clients or server. I have tried
So far I've found it impossible to produce usable tracebacks when Mako templates aren't
I've so far dabbled in Flash doing 1-man shows for quite some time, but
The only experience I have so far with a touchscreen interface was one where

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.