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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:19:05+00:00 2026-05-29T10:19:05+00:00

In .NET, why does System.Math.Round(1.035, 2, MidpointRounding.AwayFromZero) yield 1.03 instead of 1.04? I feel

  • 0

In .NET, why does System.Math.Round(1.035, 2, MidpointRounding.AwayFromZero) yield 1.03 instead of 1.04? I feel like the answer to my question lies in the section labeled “Note to Callers” at http://msdn.microsoft.com/en-us/library/ef48waz8.aspx, but I’m unable to wrap my head around the explanation.

  • 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-29T10:19:06+00:00Added an answer on May 29, 2026 at 10:19 am

    Your suspicion is exactly right. Numbers with fractional portion, when expressed as literals in .NET, are by default doubles. A double (like a float) is an approximation of a decimal value, not a precise decimal value. It is the closest value that can be expressed in base-2 (binary). In this case, the approximation is ever so vanishingly on the small side of 1.035. If you write it using an explicit Decimal it works as you expect:

    Console.WriteLine(Math.Round(1.035m, 2, MidpointRounding.AwayFromZero));
    Console.ReadKey();
    

    To understand why doubles and floats work the way they do, imagine representing the number 1/3 in decimal (or binary, which suffers from the same problem). You can’t- it translates to .3333333…., meaning that to represent it accurately would require an infinite amount of memory.

    Computers get around this using approximations. I’d explain precisely how, but I’d probably get it wrong. You can read all about it here though: http://en.wikipedia.org/wiki/IEEE_754-1985

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

Sidebar

Related Questions

Microsoft's implementation of System.Net.Mail does not provide a robust mailing solution. I would like
Why does .Net not have the System.Float type like System.String , System.Double etc.?
Does C++ has some built in timer class with same idea as .NET System.Threading.Timer
Microsoft introduced a new System.IO.MemoryMappedFiles namespace in .Net 4. Does anyone know if it
Does Qt maintain any sort of versioning information about your program like .NET does?
Possible Duplicate: Why does C# execute Math.Sqrt() more slowly than VB.NET? I'm running into
Does System.Data.OracleClient support oracle 11g? If yes which version? The .Net appplication is presently
How does the system determine whether a given DLL is a .NET DLL or
I know VB.Net does not allow implicit interface implementation like C#. And thus code
Is Web API available for .Net 3.5 SP1? The SP1 does include System.Web.Routing assembly

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.