bigint datatype accepting floating numbers

From: Chris <pghackers(at)designmagick(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: bigint datatype accepting floating numbers
Date: 2002-09-15 07:58:34
Message-ID: am1ebi$1k0g$1@news.hub.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all,

Just wondering if anyone can explain why this is happening. I thought
int2, int4, int8 all accepted integers only (according to the way the
7.2 docs read ..
http://www.postgresql.org/idocs/index.php?datatype.html#DATATYPE-NUMERIC )

test=# SELECT version();
version
------------------------------------------------------------------
PostgreSQL 7.3b1 on i586-pc-linux-gnu, compiled by GCC 2.95.3
(1 row)

test=# create table testint(smallnum int2, num int4, bignum int8);
CREATE TABLE

test=# insert into testint (smallnum) values (123.7);
ERROR: column "smallnum" is of type 'smallint' but expression is of
type 'double precision'
You will need to rewrite or cast the expression

test=# insert into testint (num) values (123.7);
ERROR: column "num" is of type 'integer' but expression is of type
'double precision'
You will need to rewrite or cast the expression

It seems to round the number too:

test=# insert into testint (bignum) values (123.7);
INSERT 17320 1

test=# SELECT * from testint;
smallnum | num | bignum
----------+-----+--------
| | 124
(1 row)

Browse pgsql-general by date

  From Date Subject
Next Message Chris 2002-09-15 08:05:49 bigint datatype accepting floating numbers
Previous Message Justin Clift 2002-09-15 04:09:12 Re: Anyone remember the name of the PostgreSQL GUI installer