Thread: change the last bit
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
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 >
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=#
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