To M. Slavin, Medcalf ans Hipp:
Thanks for your attention.
Yes, "cast(value * 1000 as integer) / 1000.0" is much better and I will
switch to your formula when possible, thanks very much.
Thank you for your offer of C functions : a trunc() function is
certainely what is needed, but I don't understand the sentence
"trunc(value, 3) which does the truncation (towards 0) and maintains precision"
What is needed is something like substr(value,1,Y) (as M. Slavin guessed
it), but on numbers rather than strings, without any alteration of the
subset returned compared to the orginal in the same range : just discard
everything above Y = nb of digits on the right side of the decimal
separator . So trunc(123.1246, 3) = trunc(123.1242, 3) = 123.124 (and
trunc(123.1, 3) = 123.1 greatly prefered to = 123.100)
Precision 1 : the need of this truncation of fp numbers is only at
storage time, (the intermediate calculus in "/expression"/ in my example
is done (in SQL) at full system-available precision of course.
Precision 2 : the number of digits kept on the right side of the decimal
separator results from mandatory external constraint, and is not a
developper's choice. With truncation, the loss of precision can, if
needed and with additional efforts, be (imperfectly) restored; I don't
know how to to do the same when rounding.
To M. Hipp :
round(123.45678, 3) returns 123.457 and what is needed is a "never
round" method : 123.456
Reason : the processing done at SQL level involves lot of
multiplications / divisions on real numbers and unfortunately "integer
arythmetics" is not an option (readability pb + error prone) . The
purpose of the truncation done here (wich I believe is a method allso
used in similar softwares) is an effort to reduce the loss of
associative property of addition over multiplication. If you send a
private mail to me I'll give more details.
Thanks
-jm
---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel
antivirus Avast.
https://www.avast.com/antivirus
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users