Re: [sqlite] round documentation

2010-05-28 Thread Matt Young
Bingo, I live and learn

On 5/28/10, Igor Tandetnik  wrote:
> Igor Tandetnik wrote:
>> Matt Young  wrote:
>>> I second that documentation confusion.  There is no truncate to
>>> integer, though I wish it would.
>>
>> Somewhat off-topic, but if you want truncation, this would do it: round(x
>> - 0.5) .
>
> Actually, cast(x as integer) works better. It follows the usual C rules,
> like (int)x for x declared as double.
> --
> Igor Tandetnik
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] round documentation

2010-05-28 Thread Igor Tandetnik
Igor Tandetnik wrote:
> Matt Young  wrote:
>> I second that documentation confusion.  There is no truncate to
>> integer, though I wish it would.
> 
> Somewhat off-topic, but if you want truncation, this would do it: round(x - 
> 0.5) .

Actually, cast(x as integer) works better. It follows the usual C rules, like 
(int)x for x declared as double.
-- 
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] round documentation

2010-05-27 Thread Matt Young
OK, got it.  I was referring to the number of decimal points, but yes
round(x,0) does do something

On 5/27/10, Igor Tandetnik  wrote:
> Matt Young wrote:
>> Round(x,0) really doesn't exist, it simply does  round(x,1)
>
> select round(4.1, 0), round(4.1, 1);
> 4.04.1
>
> --
> Igor Tandetnik
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] round documentation

2010-05-27 Thread Igor Tandetnik
Matt Young wrote:
> Round(x,0) really doesn't exist, it simply does  round(x,1)

select round(4.1, 0), round(4.1, 1);
4.04.1

-- 
Igor Tandetnik

___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] round documentation

2010-05-27 Thread Matt Young
sqlite> select round(4.-.5);
4.0
sqlite> select round(4.-0);
4.0
sqlite> select round(4);
4.0
sqlite> select round(4,0);
4.0
sqlite> select round(4,1);
4.0
sqlite> select round(4,2);
4.0
sqlite> select round(4.666,2);
4.67
sqlite>


Round(x,0) really doesn't exist, it simply does  round(x,1)

On 5/27/10, Igor Tandetnik  wrote:
> Matt Young  wrote:
>> I second that documentation confusion.  There is no truncate to
>> integer, though I wish it would.
>
> Somewhat off-topic, but if you want truncation, this would do it: round(x -
> 0.5) . Well, it's more like floor(), it goes down rather than towards zero
> (which makes a difference when x is negative).
> --
> Igor Tandetnik
>
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] round documentation

2010-05-27 Thread Igor Tandetnik
Matt Young  wrote:
> I second that documentation confusion.  There is no truncate to
> integer, though I wish it would.

Somewhat off-topic, but if you want truncation, this would do it: round(x - 
0.5) . Well, it's more like floor(), it goes down rather than towards zero 
(which makes a difference when x is negative).
-- 
Igor Tandetnik


___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] round documentation

2010-05-27 Thread Matt Young
I second that documentation confusion.  There is no truncate to
integer, though I wish it would.

On 5/27/10, Wilson, Ronald  wrote:
> From http://www.sqlite.org/lang_corefunc.html
>
> "The round(X,Y) function returns a string representation of the
> floating-point value X rounded to Y digits to the right of the decimal
> point. If the Y argument is omitted, the X value is truncated to an
> integer."
>
> The documentation above is incorrect in the last clause.  The X value is not
> truncated it is rounded to an integer.  Also, it returns a real, not an
> integer or a string.
>
> SQLite version 3.6.22
> Enter ".help" for instructions
> Enter SQL statements terminated with a ";"
> sqlite> select round(1.6);
> 2.0
> sqlite> select a, typeof(a) from (select round(1.6) as a);
> 2.0|real
> sqlite> select a, typeof(a) from (select round("1.6") as a);
> 2.0|real
> sqlite> select a, typeof(a) from (select round('1.6') as a);
> 2.0|real
> sqlite>
>
> Ron Wilson, Engineering Project Lead
> (o) 434.455.6453, (m) 434.851.1612, www.harris.com
>
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users