Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/test/round1.test # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / test / round1.test` 42 lines ยท 1310 bytes Raw Blame History 1 # 2019-05-24 2 # 3 # The author disclaims copyright to this source code. In place of 4 # a legal notice, here is a blessing: 5 # 6 # May you do good and not evil. 7 # May you find forgiveness for yourself and forgive others. 8 # May you share freely, never taking more than you give. 9 # 10 #*********************************************************************** 11 # Test cases for rounding behavior of floating point values. 12 # 13 # TESTRUNNER: slow 14 15 set testdir [file dirname $argv0] 16 source $testdir/tester.tcl 17 set testprefix round1 18 19 expr srand(0) 20 unset -nocomplain iTest 21 for {set iTest 1} {$iTest<=50000} {incr iTest} { 22 set x1 [expr int(rand()*100000)] 23 set x2 [expr int(rand()*100000)+1000*int(rand()*10000)] 24 set n [expr int(rand()*8)+1] 25 set x3 [string range [format %09d $x2] [expr {9-$n}] end] 26 set r $x1.$x3 27 set ans [string trimright $r 0] 28 if {[string match *. $ans]} {set ans ${ans}0} 29 do_test $iTest/$n/${r}4=>$ans { 30 set x [db one "SELECT round(${r}4,$n)"] 31 } $ans 32 set x4 [string range [format %09d [expr {$x2+1}]] [expr {9-$n}] end] 33 if {[string trim $x3 9]==""} {incr x1} 34 set r2 $x1.$x4 35 set ans [string trimright $r2 0] 36 if {[string match *. $ans]} {set ans ${ans}0} 37 do_test $iTest/$n/${r}6=>$ans { 38 set x [db one "SELECT round(${r}6,$n)"] 39 } $ans 40 } 41 42 finish_test