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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T17:55:33+00:00 2026-05-21T17:55:33+00:00

If you reflect over WindowsBase.dll > MS.Internal.DoubleUtil.AreClose(…) you’ll get the following code: public static

  • 0

If you reflect over WindowsBase.dll > MS.Internal.DoubleUtil.AreClose(...) you’ll get the following code:

public static bool AreClose(double value1, double value2)
{
    if (value1 == value2)
    {
        return true;
    }
    double num2 = ((Math.Abs(value1) + Math.Abs(value2)) + 10.0) * 2.2204460492503131E-16;
    double num = value1 - value2;
    return ((-num2 < num) && (num2 > num));
}

I’m trying to understand two different things:

  1. Where did they come up with the formula for num2? I guess I just don’t understand the significance of first adding the value of 10.0 and secondly multiplying all the results by this the number 2.2204460492503131E-16. Anyone know why this is the formula used?

  2. What is the point of the return statement there? It seems that by default if num2 greater than num than the negated value of num2 should be less than num. Maybe I’m missing something here, but it seems redundant. To me it’s like checking if 5 is larger than 3 and if -5 is less than 3 (as an example).

  • 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-21T17:55:34+00:00Added an answer on May 21, 2026 at 5:55 pm
    1. This appears to be a “tolerance” value that’s based on the magnitude of the numbers being compared. Note that due to how floating point numbers are represented, the smallest representable difference between numbers with an exponent of 0 is 2-53 or approximately 1.11022 × 10-16. (See unit in the last place and floating point on Wikipedia.) The constant here is exactly two times that value, so it allows for small rounding errors that have accumulated during computations.

    2. If you reorder the parameters in the conditionals, and then rename num2 to tolerance and num to diff, it should become clear.

    Viz.:

    return ((-num2 < num) && (num2 > num));
    return ((num > -num2) && (num < num2));
    return ((diff > -tolerance) && (diff < tolerance));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How to get a counter inside xsl:for-each loop that would reflect the number of
I have a broken Assembly that I want to reflect over, its not broken
During navigation of the java.lang.reflect.Method class I came across the method isBridge . Its
Python's access to environment variables does not accurately reflect the operating system's view of
Whenever we make changes to the CSS, it generally takes 24 hours to reflect
OK, having tried my first TDD attempt, it's time to reflect a little and
How can I get a list of assemblies in a given location? I'm trying
I've got a class that's got a bunch of public methods, and I'd like
I installed MVC 1.0. Where's the System.Web.MVC dll so that I can use reflector
I'm implementing a class that talks to a motor controller over a USB device.

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.