Re: [GENERAL] Should casting to integer produce same result as trunc()

2011-10-11 Thread Alban Hertroys
On 11 Oct 2011, at 2:55, Harvey, Allan AC wrote: Hi all, Had to squash timestamps to the nearest 5 minutes and things went wrong. My simple understanding of trunc() and casting to an integer says that there is a bug here. I think you may be right there, something about the rounding in

Re: [GENERAL] Should casting to integer produce same result as trunc()

2011-10-11 Thread Tom Lane
Alban Hertroys haram...@gmail.com writes: On 11 Oct 2011, at 2:55, Harvey, Allan AC wrote: My simple understanding of trunc() and casting to an integer says that there is a bug here. Which the type-cast should round to 4380103 and 4380104 respectively. It doesn't: That's because a cast from

Re: [GENERAL] Should casting to integer produce same result as trunc()

2011-10-11 Thread Alban Hertroys
On 11 October 2011 15:41, Tom Lane t...@sss.pgh.pa.us wrote: Alban Hertroys haram...@gmail.com writes: On 11 Oct 2011, at 2:55, Harvey, Allan AC wrote: My simple understanding of trunc() and casting to an integer says that there is a bug here. Which the type-cast should round to 4380103 and

Re: [GENERAL] Should casting to integer produce same result as trunc()

2011-10-11 Thread Tom Lane
Alban Hertroys haram...@gmail.com writes: On 11 October 2011 15:41, Tom Lane t...@sss.pgh.pa.us wrote: That's because a cast from float to int rounds, it doesn't truncate. I figured it would be something like that. Is that how it's defined in the SQL standard? SQL99 says Whenever

Re: [GENERAL] Should casting to integer produce same result as trunc()

2011-10-11 Thread Harvey, Allan AC
-Original Message- From: Alban Hertroys [mailto:haram...@gmail.com] Sent: Wednesday, 12 October 2011 1:35 AM To: Tom Lane Cc: Harvey, Allan AC; pgsql-general@postgresql.org Subject: Re: [GENERAL] Should casting to integer produce same result as trunc() On 11 October 2011 15:41

[GENERAL] Should casting to integer produce same result as trunc()

2011-10-10 Thread Harvey, Allan AC
Hi all, Had to squash timestamps to the nearest 5 minutes and things went wrong. My simple understanding of trunc() and casting to an integer says that there is a bug here. Expect it is my understanding though. Can someone set me straight? And thank you all for a wonderfull RDBMS. Allan