change the last bit

Поиск
Список
Период
Сортировка
Искать

change the last bit

От:
homecurr@yahoo.com
Дата:
I have a int4 coloumn, and I want to change the last bit the the
number in this column to 0. How can I do it?

Thanks,

John

Re: change the last bit

От:
Jean-Luc Lachance <jllachan@sympatico.ca>
Дата:
select a & -2::int4;


homecurr@yahoo.com wrote:
> I have a int4 coloumn, and I want to change the last bit the the
> number in this column to 0. How can I do it?
> 
> Thanks,
> 
> John
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
> 

Re: change the last bit

От:
Tony Li <tony.li@tony.li>
Дата:




On Jul 12, 2004, at 11:07 AM, homecurr@yahoo.com wrote:

> I have a int4 coloumn, and I want to change the last bit the the
> number in this column to 0. How can I do it?
>

cfgtools=# \d delme
      Table "public.delme"
  Column |  Type   | Modifiers
--------+---------+-----------
  num    | integer |

cfgtools=# select * from delme;
  num
-----
    3
    4
    5
(3 rows)

cfgtools=# update delme set num = num & x'fffffffe'::int4 where num = 3;
UPDATE 1
cfgtools=# select * from delme;
  num
-----
    4
    5
    2
(3 rows)

cfgtools=#

Re: change the last bit

От:
mike g <mike@thegodshalls.com>
Дата:
What do you want to change it to?

Another number?  Use something like Update table set field = field + 1

I assume you are going to store the result in the same table column?


On Mon, 2004-07-12 at 13:07, homecurr@yahoo.com wrote:
> I have a int4 coloumn, and I want to change the last bit the the
> number in this column to 0. How can I do it?
> 
> Thanks,
> 
> John
> 
> ---------------------------(end of broadcast)---------------------------
> TIP 7: don't forget to increase your free space map settings
FAQ