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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:41:53+00:00 2026-05-16T08:41:53+00:00

I was doing some unit testing at work and a peculiar error popped up

  • 0

I was doing some unit testing at work and a peculiar error popped up for one of the assertions. Note that expectedValue and actualValue are both doubles.

Assert.AreEqual(expectedValue, actualValue);

The exception stated that they were not equal, elaborating that “expected value: <6.8> actual value: <6.8>.”

The expected value is a hard coded 6.8 and the actual value is formulated using database values going through our classification methods (such as Equal Records, or Jenks Natural Breaks).

My guess is that the difference is probably that the mantissas of the 2 values are similar up until the least significant bit. I updated the tests to include an epsilon to find if the two values are close enough, but I’m curious to if there is a way to force the mantissa to match with the display value of if I displayed that double. Does such a mantissa correction exist?

  • 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-16T08:41:53+00:00Added an answer on May 16, 2026 at 8:41 am

    I’m not entirely sure what you mean by forcing the mantissa to match the display value… there are no double values which are exactly 0.1, for example.

    If you want some code to display the exact value of a double, however, I have a DoubleConverter.cs file which makes it easy:

     double d = 0.1;
     string x = DoubleConverter.ToExactString(d);
    

    Another alternative is to use the round-trip format specifier (“r”) when converting a double to string – that guarantees that the result has enough information to reproduce the same exact value later. In other words, if x != y, then x.ToString("r") != y.ToString("r").

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

Sidebar

Ask A Question

Stats

  • Questions 493k
  • Answers 493k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Take a look at the answer to WPF ListBox Scroll… May 16, 2026 at 10:43 am
  • Editorial Team
    Editorial Team added an answer Assuming you are having problem with <head runat="server"> tag, and… May 16, 2026 at 10:43 am
  • Editorial Team
    Editorial Team added an answer Depends. If you need the space to be left blank,… May 16, 2026 at 10:43 am

Trending Tags

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

Top Members

Related Questions

I was doing some unit testing on code that could throw a number of
I am currently doing some work for a company that runs a legacy web
I am trying to learn unit testing. I am trying to unit test some
Is there any point in Unit-Testing a method that the only thing it does
I'm trying to use PHPUnit to unit test some class methods that return SQL.
I'm doing some routine in Java (1.5)+Swing, that damands some time. How the best
What are some of the open source projects out there that you would hold
I've been using MSTest so far for my unit-tests, and found that it would
I am doing some custom development for a client on their miva shopping cart
I'm doing some transforms using xlinq and some of those transforms can result in

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.