Skip site navigation (1) Skip section navigation (2)

Re: BUG #4114: Inconsistent shift operator

From: Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>
To: Roman Kononov <kononov(at)dls(dot)net>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #4114: Inconsistent shift operator
Date: 2008-04-20 18:17:50
Message-ID: 480B88CE.3010202@sun.com (view raw or flat)
Thread:
Lists: pgsql-bugs
Roman Kononov napsal(a):
> The following bug has been logged online:
> 
> Bug reference:      4114
> Logged by:          Roman Kononov
> Email address:      kononov(at)dls(dot)net
> PostgreSQL version: 8.3.1
> Operating system:   x86_64 GNU/Linux
> Description:        Inconsistent shift operator
> Details: 
> 
> The below test cases show the obvious inconsistency between different
> integer types.
> 
> test=# \t
> Showing only tuples.
> test=# select 1::int2 << 17;
>          0
> 
> test=# select 1::int4 << 33;
>          2
> 
> test=# select 1::int8 << 65;
>          2
> 
> test=# select 2::int2 >> 17;
>          0
> 
> test=# select 2::int4 >> 33;
>          1
> 
> test=# select 2::int8 >> 65;
>          1

It seems to be OK regarding how C shift operator works. Try

#include <stdio.h>
#include <inttypes.h>

void fce(int16_t arg1, int32_t arg2)
{
         int16_t res = arg1 << arg2;
         printf("result: %i\n", res);
}

int main()
{
         fce(1,17);
         return 0;
}



		Zdenek

In response to

Responses

pgsql-bugs by date

Next:From: Sam MasonDate: 2008-04-20 18:58:59
Subject: Re: Inconsistent shift operator
Previous:From: Peter EisentrautDate: 2008-04-20 17:08:00
Subject: Re: Inconsistent shift operator

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group