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

  • Home
  • SEARCH
  • 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 6144727
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:41:37+00:00 2026-05-23T18:41:37+00:00

As far as I know float can represent 14 numbers precisely. So let’s say

  • 0

As far as I know float can represent 14 numbers precisely.

So let’s say we have

a = 564214623154
b = 54252

and we multiply this
c=a*b and it should be 30609771735350808 but when compiled it shows me 3.0609771735351E+16
So as I understand it should lose some precision but when I divide c by a
c/a I get 564214623154 exact result without any precision lost

another example lets say we have

c = 30609771735350808 
d = 30609761111111111

e=c-d should be 10624239697 but when compiled it shows me 10624239696 so precision is lost

So is precision lost only when I subtract or add two numbers?

If it matters I use php

  • 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-23T18:41:37+00:00Added an answer on May 23, 2026 at 6:41 pm

    It is possible to lose precision with multiplication and division also. PHP and JavaScript store numbers in IEEE-754 format with 52 bits of mantissa and 11 bits of exponent. Some integers are represented exactly and some are not.

    Let’s try these:

    In Real Math (generated with Ruby):

    45345657434523 * 9347287748322342 / 74387422372 = 5697991604786167788
    

    In PHP and JavaScript

    45345657434523 * 9347287748322342 / 74387422372 = 5697991604786168000
    

    So we lose precision with multiplication and division also.

    EDIT: On revisiting the OP’s question it seems like this was not a great answer, because the result contained over 15 decimal digits of precision. If the intent of the question is whether multiplying and dividing a bunch of numbers each of which was represented in 15 digits of precision or less, then the final result tends to keep a good deal of precision (provided you don’t overflow or underflow). So you can multiply 1.25E35 * 2.5E7 and get precisely 3.125e+42 because PHP and JavaScript will essentially multiply the groups of significant figures and add up the exponents. However, if you ADD those two values you get 1.25E35 + 2.5E7 = 1.25E35. That’s right, you add 25 million to a number and it does not change! That is because, as the OP says, you only get 14 or 15 decimal digits of precision. Try adding those two values by hand by writing out 120000000000000000000000000000000000 + 25000000. The 14-15 digits start counting from the left and you can’t pick them all up.

    Bottom line is precision problems are more likely to arise with addition and subtraction. Good to be aware of.

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

Sidebar

Related Questions

As far as I know, in gcc you can write something like: #define DBGPRINT(fmt...)
In Ruby 1.9 you can have Fixnum , Float , and Symbol values that
I have an std::map<std::string, float> so I can do quick lookups for float values
As far as know, I must be careful with PHP, and I think Javascript.
As far as I know, foreign keys (FK) are used to aid the programmer
As far as I know, Flash has to pass info off to another external
As far as i know it is not possible to do the following in
As far as I know (not much I'll admit), the currently popular programming paradigms
As far as I know, there's no way to use {% include %} within
As far as i know, there is no direct equivalent in C#. My current

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.