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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:58:26+00:00 2026-05-28T02:58:26+00:00

I have a field radius in my database of the type float and of

  • 0

I have a field radius in my database of the type float and of value 0.0.

Through a PHP sript I change it’s value to the content of d2, with this statement, to 32.422:

$res=mysql_query("UPDATE `astros` SET `radius` = `radius` + ".$d2." WHERE `index` = '".$index."'");

If later I use another PHP script to reduce the value of the radius in the same amount:

$res=mysql_query("UPDATE `astros` SET `radius` = `radius` - ".$d2." WHERE `index` = '".$index."'");

the final value isn’t 0, like it should be, but 1.4988E-9… almost zero.

Can anyone tell me what am I doing wrong?

Thanks,
Direz

  • 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-28T02:58:26+00:00Added an answer on May 28, 2026 at 2:58 am

    There is nothing wrong, you are just seing the limitation of the floating point numbers.

    What you think is the exact value 32.422 isn’t so. When converted from the textual representation in the query into a floating point number used by the database, it becomes the closest number that is possible to represent using that data type. It could be something like 32.421999995662, very close to 32.422 but not exactly.

    Each floating point value may contain such a deviation from the value that you intended, and when you do calculations with them the deviations add up, and after a while you see the difference.

    Normally the small differences isn’t visible, as the numbers are rounded to a reasonable number of digits when you display them. If you for example subtracted 31.422 in the second query, you would end up with something that is very close to 1, for example 1.00000000014988, which would be rounded to 1.000000000 when you display it. As you are getting a value close to zero, there is no value substantially larger than the deviation that it could round to, so you see only the deviation.

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

Sidebar

Related Questions

i have field with content like this: 1, 2, 100 first two numbers can
I have field like a_b_c_d I want as the output a b c_d, this
I have a field type varchar in sql server. It contains data like 010109
I have done autocomplete for my php code usign ajax.I used this code for
i have field Tdate (text type) on my Table MyTbl i need query that
I have field in my sql table named 'content'. I have 300 records in
i have field in mysql type varchar with field data contains code, and the
I have field X that contains text with spaces in the end of the
in my jqgrid i have field in a table which represents the id and
I my index lets say I have field field named full_name. I'm doing following

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.