Home Page for the TeradataForum
 

Archives of the TeradataForum

Message Posted: Thu, 09 Oct 2003 @ 19:48:43 GMT


     
  <Prev Next>   <<First <Prev Next> Last>>  


Subj:   Re: Bitwise operations
 
From:   Dieter Noeth

Figge, Jason wrote:

  Does anyone know if Teradata can perform bitwise operations?  


  I.e.  


  (x & 1) = 1
(x & 2) = 2
(x & 4) = 4
 


  I know I can do:  


  case when x in (1,3,5,7,9) then 1 else 0 end
case when x in (2,3,6,7) then 2 else 0 end
case when x in (4,5,6,7) then 4 else 0 end
 


  but this implies a closed world assumption and it's a little too restrictive for my liking  



If it's only a single bit:

x / 1 mod 2 * 1
x / 2 mod 2 * 2
x / 4 mod 2 * 4


If you only want to know if that bit is set:

x / 1 mod 2
x / 2 mod 2
x / 4 mod 2


Dieter



     
  <Prev Next>   <<First <Prev Next> Last>>  
 
 
 
 
 
 
 
 
  
  Top Home Privacy Feedback  
 
 
Copyright for the TeradataForum (TDATA-L), Manta BlueSky    
Copyright 2016 - All Rights Reserved    
Last Modified: 15 Jun 2023