Hello,

Below is a recipe on a "best effort" basis, to truncate fp numbers on the right side of the decimal separator with SQLite.

It is not intended to correct any fp numbers processing, but only to discard, without any rounding, unwanted fractional digits.

The following is directed to discard all digits of a number after the third fractional position (slight and easy adjustments must be done for different positional truncations) :

    round(  CAST(/expression/ AS INTEGER)

              + /((expression/  * 1000 % 1000 ) / 1000 ), 3)

(round() is used against eventually imprecise representation resulting from the top level addition operation)

Caveat : force an eventual INTEGER representation resulting from /expression/ to its equivalent REAL representation (ie : x -> x.0)

(not a pb for me)

Improvements/comments welcome (and wil be happy when an equivalent function finds its way into SQLite)

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

Reply via email to