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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:05:01+00:00 2026-05-27T11:05:01+00:00

I just read a book about javascript. The author mentioned a floating point arithmetic

  • 0

I just read a book about javascript. The author mentioned a floating point arithmetic rounding error in the IEEE 754 standard.

For example adding 0.1 and 0.2 yields 0.30000000000000004 instead of 0.3.

so (0.1 + 0.2) == 0.3 returns false.

I also reproduced this error in c#.

So these are my question is:

How often this error occurs?
What is the best practice workaround in c# and javascript?
Which other languages have the same error?

  • 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-27T11:05:02+00:00Added an answer on May 27, 2026 at 11:05 am

    It’s not an error in the language. It’s not an error in IEEE 754. It’s an error in the expectation and usage of binary floating point numbers. Once you understand what binary floating point numbers really are, it makes perfect sense.

    The best practice in C# is to use System.Decimal (aka decimal) which is a decimal floating point type, whenever you’re dealing with quantities which are naturally expressed in decimal – typically currency values.

    See my articles on .NET binary floating point and decimal floating point for more information.

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

Sidebar

Related Questions

I just read about the breadth-first search algorithm in the Introduction to Algorithms book
Just began learning about algorithms in c++. My book mentions a simple read-only algorithm
I've read the whole Dragon Book recently (just for fun, I'm not really planning
I just read this post about why new-line warnings exist, but to be honest
I just read this statement in a java book saying Objects in java reside
I just read the WebDAV Appendex in the O'Reilly Subversion book. I don't quite
Recently I have read about hash-tables in a very famous book Introduction to Algorithms
Over the past couple of weeks I've read through the book Error Control Coding:
I've read in Stoyan Stefanov book about single var pattern. Also it's good by
Almost every Java book I read talks about using the interface as a way

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.