Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Update the FAQ to include an entry about binary versus decimal numbers. (CVS 2648) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
0bbe73fccfe52700c2ae1122388764e8 |
User & Date: | drh 2005-08-31 02:46:21.000 |
Context
2005-08-31
| ||
03:13 | Refinements to the optimizer overview and integration into the website. (CVS 2649) (check-in: ccd12e9e79 user: drh tags: trunk) | |
02:46 | Update the FAQ to include an entry about binary versus decimal numbers. (CVS 2648) (check-in: 0bbe73fccf user: drh tags: trunk) | |
01:49 | Adding the first cut of the optimizer overview document. (CVS 2647) (check-in: 4c8d0a4c26 user: drh tags: trunk) | |
Changes
Changes to www/faq.tcl.
1 2 3 | # # Run this script to generated a faq.html output file # | | | 1 2 3 4 5 6 7 8 9 10 11 | # # Run this script to generated a faq.html output file # set rcsid {$Id: faq.tcl,v 1.30 2005/08/31 02:46:21 drh Exp $} source common.tcl header {SQLite Frequently Asked Questions</title>} set cnt 1 proc faq {question answer} { set ::faq($::cnt) [list [string trim $question] [string trim $answer]] incr ::cnt |
︙ | ︙ | |||
479 480 481 482 483 484 485 486 487 488 489 490 491 492 | ** SQLITE_SCHEMA. In this case the loop will execute again. */ rc = sqlite3_finalize(pStmt); } while( rc==SQLITE_SCHEMA ); </pre></blockquote> } # End of questions and answers. ############# puts {<h2>Frequently Asked Questions</h2>} # puts {<DL COMPACT>} | > > > > > > > > > > > > > > > > > > > | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 | ** SQLITE_SCHEMA. In this case the loop will execute again. */ rc = sqlite3_finalize(pStmt); } while( rc==SQLITE_SCHEMA ); </pre></blockquote> } faq {Why does ROUND(9.95,1) return 9.9 instead of 10.0? Shouldn't 9.95 round up?} { <p>SQLite uses binary arithmetic and in binary, there is no way to write 9.95 in a finite number of bits. The closest to you can get to 9.95 in a 64-bit IEEE float (which is what SQLite uses) is 9.949999999999999289457264239899814128875732421875. So when you type "9.95", SQLite really understands the number to be the much longer value shown above. And that value rounds down.</p> <p>This kind of problem comes up all the time when dealing with floating point binary numbers. The general rule to remember is that most fractional numbers that have a finite representation in decimal do not have a finite representation in binary. And so they are approximated using the closest binary number available. That approximation is usually very close, but it will be slightly off and in some cases can cause your results to be a little different from what you might expect.</p> } # End of questions and answers. ############# puts {<h2>Frequently Asked Questions</h2>} # puts {<DL COMPACT>} |
︙ | ︙ |