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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T19:40:01+00:00 2026-05-30T19:40:01+00:00

How do people deal with floating point inaccuracy in ANSI C? In this case,

  • 0

How do people deal with floating point inaccuracy in ANSI C? In this case, there is an expected result of 4.305, but ANSI C returns an additional 0.000001?

#include<stdio.h>
main()
{
  float _lcl1=66.3;
  float _ucl1=76;
  float lbl1 = 0;
  float ubl1 = 0;
  lbl1 = (_lcl1 - 2.5 * (_ucl1 - _lcl1));
  printf ("%e\n",lbl1);
}

4.205001e+01

Ideas I have are that this must be a common issue so there is a standard lib to deal with this or people convert these to integers, do the calculation, and then convert them back? Can someone provide some insight on a successful “in practice” strategy?

  • 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-30T19:40:02+00:00Added an answer on May 30, 2026 at 7:40 pm

    This has nothing to do with ANSI C and everything to do with floating point arithmetic.

    You should read:
    “What Every Computer Scientist Should Know About Floating-Point Arithmetic”
    http://www.math.umd.edu/~jkolesar/mait613/floating_point_math.pdf

    To give an inadequate summary, floating point arithmetic is not a magic infinite precision mechanism — it is an approximate way of representing an infinite set of real numbers using a small (typically 32 or 64) number of bits. It does its work in binary, not in decimal, and the fractions exactly representable in binary are not the same as those exactly representable in decimal. Rounding is an issue, as is the interval between floats.

    Anyway, you really should read the above paper if you are a working programmer. There is far more to this than one can describe in a few paragraphs on Stack Overflow and the topic is very important.

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

Sidebar

Related Questions

People use gdb on and off for debugging, of course there are lots of
What's the proper way to deal with a web page that returns results of
I usually have to deal with a lot of people sending me Windows files
I'm curious how people deal with coupling between tests, and cascaing failures. I don't
I'm wondering how people in general deal with adding behavior to EMF models. I
I've gone through several similar questions, none seem to deal with this type of
how do people deal with extra data needed to render a list. eg I
How do people deal with a scheduled NSTimer when an app is in the
OK, not that kind of hostile. I'm curious to hear how people deal with
All the examples I've seen deal with branches where there is only one committer.

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.