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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T04:10:55+00:00 2026-05-24T04:10:55+00:00

Possible Duplicate: Why are these numbers not equal? The below expression, which evaluates to

  • 0

Possible Duplicate:
Why are these numbers not equal?

The below expression, which evaluates to 0.1, is considered larger than 0.1.

> round(1740/600,0) - 1740/600
[1] 0.1
> (round(1740/600,0) - 1740/600) <= 0.1
[1] FALSE //???!!???
> (round(1740/600,0) - 1740/600) <= 0.1000000000000000000000000000000000000001
[1] TRUE

Thinking that the issue might be due to rounding I tried this with the same result:

> 3 - 2.9
[1] 0.1
> (3 - 2.9) <=0.1
[1] FALSE

So, what gives and how do I fix it without fudging the cutoff?

  • 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-24T04:10:56+00:00Added an answer on May 24, 2026 at 4:10 am

    From the Floating-Point Guide:

    Why don’t my numbers, like 0.1 + 0.2 add up to a nice round 0.3, and
    instead I get a weird result like 0.30000000000000004?

    Because internally, computers use a format (binary floating-point)
    that cannot accurately represent a number like 0.1, 0.2 or 0.3 at all.

    When the code is compiled or interpreted, your “0.1” is already
    rounded to the nearest number in that format, which results in a small
    rounding error even before the calculation happens.

    What can I do to avoid this problem?

    That depends on what kind of calculations you’re doing.

    • If you really need your results to add up exactly, especially when
      you work with money: use a special decimal datatype.
    • If you just
      don’t want to see all those extra decimal places: simply format your
      result rounded to a fixed number of decimal places when displaying it.
    • If you have no decimal datatype available, an alternative is to work
      with integers, e.g. do money calculations entirely in cents. But this
      is more work and has some drawbacks.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: slow android emulator My tablet is not here yet, which is why
Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i ,
Possible Duplicate: Why does C# execute Math.Sqrt() more slowly than VB.NET? I'm running into
Possible Duplicate: Android SMS Receiver not working I am in the beginning stages of
Possible Duplicate: Easy interview question got harder: given numbers 1..100, find the missing number(s)
Possible Duplicate: ( POD )freeing memory : is delete[] equal to delete ? Does
Possible Duplicate: Howto build a SQL statement with using IDs that might not be
Possible Duplicate: Validate numbers in JavaScript - IsNumeric() var miscCharge = $(#miscCharge).val(); I want
Possible Duplicate: Converting words to numbers in PHP Is there a php function to
Possible Duplicate: How can I count the numbers of rows that a mysql query

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.