On Thursday, 18 October, 2018 14:13, Richard Hipp <d...@sqlite.org> wrote:

>On 10/18/18, John Harney <john.har...@grupobimbo.com> wrote:

>> Recently figured this out.  Seems to work fine

>> trim(trim(round(1.111,0),'0'),'.')   = 1

>CAST(1.111 AS integer)

That should be CAST(round(x,0) as integer) if you want the rounded result as an 
actual integer (the bare CAST truncates).  Note however that the default 
builtin round() function does "round half away from 0" and not "round half to 
even" rounding, so beware of using the result in further calculations ...

sqlite> select cast(1.111 as integer);
1
sqlite> select cast(1.5 as integer);
1
sqlite> select cast(1.6 as integer);
1
sqlite> select cast(round(1.6,0) as integer);
2
sqlite> select cast(round(1.5,0) as integer);
2
sqlite> select cast(round(2.5,0) as integer);
3
sqlite> select cast(roundhe(2.5,0) as integer);
2

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.





_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to