pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedMath Huh?
7+ messages / 5 participants
[nested] [flat]
* Math Huh?
@ 2002-05-30 23:29 Josh Berkus <josh@agliodbs.com>
2002-05-30 23:42 ` Re: Math Huh? Larry Rosenman <ler@lerctr.org>
2002-05-30 23:43 ` Re: Math Huh? Tom Lane <tgl@sss.pgh.pa.us>
2002-05-30 23:48 ` Re: Math Huh? David Stanaway <david@stanaway.net>
2002-05-31 06:36 ` Re: Math Huh? Achilleus Mantzios <achill@matrix.gatewaynet.com>
0 siblings, 4 replies; 7+ messages in thread
From: Josh Berkus @ 2002-05-30 23:29 UTC (permalink / raw)
To: pgsql-sql
Folks,
I'll let this session speak for itself:
jwnet=> select version();
version
---------------------------------------------------------------
PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.3
(1 row)
jwnet=> select (255 * 255 * 255 * 255);
?column?
-----------
-66716671
(1 row)
So, a bug, or what?
--
-Josh Berkus
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Math Huh?
2002-05-30 23:29 Math Huh? Josh Berkus <josh@agliodbs.com>
@ 2002-05-30 23:42 ` Larry Rosenman <ler@lerctr.org>
3 siblings, 0 replies; 7+ messages in thread
From: Larry Rosenman @ 2002-05-30 23:42 UTC (permalink / raw)
To: josh@agliodbs.com; +Cc: pgsql-sql
On Thu, 2002-05-30 at 18:29, Josh Berkus wrote:
> Folks,
>
> I'll let this session speak for itself:
>
> jwnet=> select version();
> version
> ---------------------------------------------------------------
> PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.3
> (1 row)
>
> jwnet=> select (255 * 255 * 255 * 255);
> ?column?
> -----------
> -66716671
> (1 row)
>
> So, a bug, or what?
>
You exceeded a SIGNED int4..
ler=# select (255*255*255*255)
ler-# ;
?column?
-----------
-66716671
(1 row)
ler=# select (255::int8*255::int8*255::int8*255::int8);
?column?
------------
4228250625
(1 row)
ler=# select version();
version
---------------------------------------------------------------------
PostgreSQL 7.2.1 on i386-portbld-freebsd4.6, compiled by GCC 2.95.3
(1 row)
ler=#
>
> --
> -Josh Berkus
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Math Huh?
2002-05-30 23:29 Math Huh? Josh Berkus <josh@agliodbs.com>
@ 2002-05-30 23:43 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-05-30 23:59 ` Re: Math Huh? Josh Berkus <josh@agliodbs.com>
3 siblings, 1 reply; 7+ messages in thread
From: Tom Lane @ 2002-05-30 23:43 UTC (permalink / raw)
To: josh@agliodbs.com; +Cc: pgsql-sql
Josh Berkus <josh@agliodbs.com> writes:
> jwnet=> select (255 * 255 * 255 * 255);
> ?column?
> -----------
> -66716671
> (1 row)
> So, a bug, or what?
(yawn) int4 overflow. Use float or numeric if you want overflow
robustness...
regards, tom lane
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Math Huh?
2002-05-30 23:29 Math Huh? Josh Berkus <josh@agliodbs.com>
2002-05-30 23:43 ` Re: Math Huh? Tom Lane <tgl@sss.pgh.pa.us>
@ 2002-05-30 23:59 ` Josh Berkus <josh@agliodbs.com>
2002-05-31 00:36 ` Re: Math Huh? Larry Rosenman <ler@lerctr.org>
0 siblings, 1 reply; 7+ messages in thread
From: Josh Berkus @ 2002-05-30 23:59 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-sql
Tom,
> (yawn) int4 overflow. Use float or numeric if you want overflow
> robustness...
Shouldn't it give me an error? This does:
SELECT (255^4)::INT4
--
-Josh Berkus
______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh@agliodbs.com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Math Huh?
2002-05-30 23:29 Math Huh? Josh Berkus <josh@agliodbs.com>
2002-05-30 23:43 ` Re: Math Huh? Tom Lane <tgl@sss.pgh.pa.us>
2002-05-30 23:59 ` Re: Math Huh? Josh Berkus <josh@agliodbs.com>
@ 2002-05-31 00:36 ` Larry Rosenman <ler@lerctr.org>
0 siblings, 0 replies; 7+ messages in thread
From: Larry Rosenman @ 2002-05-31 00:36 UTC (permalink / raw)
To: josh@agliodbs.com; +Cc: Tom Lane <tgl@sss.pgh.pa.us>; pgsql-sql
On Thu, 2002-05-30 at 18:59, Josh Berkus wrote:
>
> Tom,
>
> > (yawn) int4 overflow. Use float or numeric if you want overflow
> > robustness...
>
> Shouldn't it give me an error? This does:
>
> SELECT (255^4)::INT4
Why? You're doing 3 multiplications, instead of one power. It has no
idea what the number is.
>
>
> --
> -Josh Berkus
>
> ______AGLIO DATABASE SOLUTIONS___________________________
> Josh Berkus
> Complete information technology josh@agliodbs.com
> and data management solutions (415) 565-7293
> for law firms, small businesses fax 621-2533
> and non-profit organizations. San Francisco
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org
>
--
Larry Rosenman http://www.lerctr.org/~ler
Phone: +1 972-414-9812 E-Mail: ler@lerctr.org
US Mail: 1905 Steamboat Springs Drive, Garland, TX 75044-6749
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Math Huh?
2002-05-30 23:29 Math Huh? Josh Berkus <josh@agliodbs.com>
@ 2002-05-30 23:48 ` David Stanaway <david@stanaway.net>
3 siblings, 0 replies; 7+ messages in thread
From: David Stanaway @ 2002-05-30 23:48 UTC (permalink / raw)
To: pgsql-sql
On Thu, 2002-05-30 at 18:29, Josh Berkus wrote:
> Folks,
>
> I'll let this session speak for itself:
>
> jwnet=> select version();
> version
> ---------------------------------------------------------------
> PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.3
> (1 row)
>
> jwnet=> select (255 * 255 * 255 * 255);
> ?column?
> -----------
> -66716671
> (1 row)
scratch=# select (255 * 255 * 255 * 255::int8);
?column?
------------
4228250625
(1 row)
$ bc -l
obase=16
4228250625
FC05FC01
^
You have overflowed a signed integer as the most significant bit is set.
--
David Stanaway
Attachments:
signature.asc (application/pgp-signature, 480B) download
^ permalink raw reply [nested|flat] 7+ messages in thread
* Re: Math Huh?
2002-05-30 23:29 Math Huh? Josh Berkus <josh@agliodbs.com>
@ 2002-05-31 06:36 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
3 siblings, 0 replies; 7+ messages in thread
From: Achilleus Mantzios @ 2002-05-31 06:36 UTC (permalink / raw)
To: Josh Berkus <josh@agliodbs.com>; +Cc: pgsql-sql
On Thu, 30 May 2002, Josh Berkus wrote:
> Folks,
>
> I'll let this session speak for itself:
>
> jwnet=> select version();
> version
> ---------------------------------------------------------------
> PostgreSQL 7.2.1 on i686-pc-linux-gnu, compiled by GCC 2.95.3
> (1 row)
>
> jwnet=> select (255 * 255 * 255 * 255);
> ?column?
> -----------
> -66716671
> (1 row)
>
> So, a bug, or what?
Dear Josh, i686-pc-linux-gnu
^^^
the 686 arch is the answer.
dynacom=# select (255::int8 * 255 * 255 * 255);
?column?
------------
4228250625
(1 row)
dynacom=#
>
>
>
--
Achilleus Mantzios
S/W Engineer
IT dept
Dynacom Tankers Mngmt
tel: +30-10-8981112
fax: +30-10-8981877
email: achill@matrix.gatewaynet.com
mantzios@softlab.ece.ntua.gr
^ permalink raw reply [nested|flat] 7+ messages in thread
end of thread, other threads:[~2002-05-31 06:36 UTC | newest]
Thread overview: 7+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2002-05-30 23:29 Math Huh? Josh Berkus <josh@agliodbs.com>
2002-05-30 23:42 ` Larry Rosenman <ler@lerctr.org>
2002-05-30 23:43 ` Tom Lane <tgl@sss.pgh.pa.us>
2002-05-30 23:59 ` Josh Berkus <josh@agliodbs.com>
2002-05-31 00:36 ` Larry Rosenman <ler@lerctr.org>
2002-05-30 23:48 ` David Stanaway <david@stanaway.net>
2002-05-31 06:36 ` Achilleus Mantzios <achill@matrix.gatewaynet.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox