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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:51:34+00:00 2026-05-26T10:51:34+00:00

I’m learning more then I ever wanted to know about Floating point numbers. Lets

  • 0

I’m learning more then I ever wanted to know about Floating point numbers.

Lets say I needed to add:

1 10000000 00000000000000000000000

1 01111000 11111000000000000000000

2’s complement form.

The first bit is the sign, the next 8 bits are the exponent and the last 23 bits are the mantisa.

Without doing a conversion to scientific notation, how do I add these two numbers? Can you walk through it step by step?

any good resources for this stuff? Videos and practice examples would be great.

  • 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-26T10:51:34+00:00Added an answer on May 26, 2026 at 10:51 am

    You have to scale the numbers so that they have the same exponent. Then you add the mantissa fields and, if necessary, normalise the result.

    Oh, yes, and if they’re different signs, you just call your subtraction function instead 🙂

    Let’s do an example in decimal since it’s easier to understand. Let’s further assume they’re stored with only eight digits to the right of the decimal (and the numbers are between 0 inclusive and 1 exclusive).

    Add the two numbers:

    sign  exponent  mantissa  value
       1        42  18453284  + 0.18453284 x 10^42
       1        38  17654321  + 0.17654321 x 10^38
    

    Scaling these numbers to the highest exponent gives something where you can add the mantissa fields.:

    sign  exponent  mantissa  value
       1        42  18453284  + 0.18453284 x 10^42
       1        42      1765  + 0.00001765 x 10^42
       =        ==  ========
       1        42  18455049  + 0.18455049 x 10^42
    

    And there you have your number. This also illustrates how accuracy can be lost due to the shifting. For example, IEEE754 single precision floats will have:

    1e38 + 1e-38 = 1e38
    

    such as with:

    #include <stdio.h>
    int main (void) {
        float f1 = 1e38;
        float f2 = 1e-38;
        float f3 = f1 + f2;
        float f4 = f1 - f3;
        printf ("%.50f\n", f4);
        return 0;
    }
    

    In terms of what happens with overflow, that’s part of the normalisation I mentioned. Let’s add 99999.9999 to 99999.9993. Since they already have the same exponent, no need to scale, so we just add:

    sign  exponent  mantissa  value
       1         5  99999999  + 0.99999999 x 10^5
       1         5  99999993  + 0.99999999 x 10^5
       =        ==  ========
       1         5 199999992  ???
    

    You can see here that we have a carry situation so we can’t put that carry into the number, being limited to eight digits. What we do then is to shift the number to the right so that we can insert the carry. Since that shift is effectively a divide-by-ten, we have to increment the exponent to counter that.

    So:

    sign  exponent  mantissa  value
       1         5 199999992  ???
    

    becomes:

    sign  exponent  mantissa  value
       1         6  19999999  + 0.19999999 x 10^6
    

    In reality, it’s not just a simple right-shift since you need to round to the nearest number. If the number you’re shifting out is five or more, you need to add one to the digit on the left. That’s why I chose 99999.9993 as the second number. If I had added 99999.9999 to itself, I would have ended up with:

    sign  exponent  mantissa  value
       1         5 199999998  ???
    

    which, on right shift, would have triggered quite a few carries towards the left:

    sign  exponent  mantissa  value
       1         6  20000000  + 0.2 x 10^6
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Does anyone know how can I replace this 2 symbol below from the string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is

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.