If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > easy question for thos with experience...

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-24-03, 16:44
noamkrief noamkrief is offline
Registered User
 
Join Date: Dec 2003
Posts: 61
easy question for thos with experience...

here's my query.

$result = mysql_query("SELECT SUM(DAY+NIGHT) AS TOTALTIME FROM MAIN", $db);
$myrow = mysql_fetch_array($result);
extract ($myrow);
echo ("<br>$TOTALTIME<br>");

In my database, Night = 1.2 and Day = 0.7

The answer should come up as 1.9 right?
Well,
I'm getting:

1.9000000357628


The first couple of decimal points are always correct, but then i get a bunch of numbers in the back

any clude why?
thanks
Noam
Reply With Quote
  #2 (permalink)  
Old 12-24-03, 17:04
sundialsvcs sundialsvcs is offline
Registered User
 
Join Date: Oct 2003
Posts: 706
Lightbulb

Quote:
Honahble Sahn say ...
"Floating point number like pile of sand on the ground. Each time you pick one up and move it, you lose a little sand and pick up a little dirt."
You are always going to find a certain amount of imprecision in any floating point calculation. (Even those performed by your trusty pocket calculator.)

This includes: imprecision during the calculation; truncation that can occur when storing the value in memory areas of various sizes; errors that occur in translating your character input into binary; and errors which occur in translating the binary data to decimal characters for your viewing pleasure!

It's normal. Every computer application, not just MySQL, exhibits this behavior.
__________________
ChimneySweep(R): fast, automatic
table repair at a click of the
mouse! http://www.sundialservices.com
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On