Bitwise Operator

Hi Gurus,
I am bit poor at math and yes i know bitand is used for binary and operation. But i can't figure out this conversion.
Here is a flag column values from ts$
flags   0x40 = COMPRESS
         0x10000 = OLTP Compression
         0x20000 = Columnar Low Compression
         0x40000 = Columnar High Compression
         0x80000 = Archive CompressionAnd here is corrosponding conversion in dba_tablespaces script.
case when bitand(ts.flags,  65536) = 65536  then 'OLTP'
                  when bitand(ts.flags, (131072+262144)) = 131072
                    then 'QUERY LOW'
                  when bitand(ts.flags, (131072+262144)) = 262144
                    then 'QUERY HIGH'
                  when bitand(ts.flags, (131072+262144)) = (131072+262144)
                    then 'ARCHIVE LOW'
                  when bitand(ts.flags, 524288) = 524288
                    then 'ARCHIVE HIGH'
                  else 'BASIC' end))Now, here are my question
1. 0x40 & 0x10000 and othere are hexa values Right ?
2. So what does 65536 means here all other values are multiple (131072) are of this
3. So, what are we checking here with this kind of bitand(ts.flags, (131072+262144)) thing
Can someone please explain in simple terms. I searched manuals and other but they give just high level information but not basic.

decimal 65536 is the same as hexadecimal 10000
You can test it useing a calculator or SQL
select to_char(65536,'fmXXXXXX') hexConversion from dual;
HEXCONVERSION
10000BITAND is used to test if a certain bit is set or not. For example in your case it is used to test if the bits for ARCHIVE + LOW COMPRESSION are set.
Hex 10000 in Binary code (not HEX) looks like this
0x10000  => 0000100000000 .... many 0s
0x20000  => 0001000000000 .... many 0s
0x40000  => 0010000000000 .... many 0s
0x80000  => 0100000000000 .... many 0s Bitand does a binary AND operation on each bit. Therefore it can be used to find out if certain bits are set or not.
example
1000111010001
BITAND
0000110000000
0000110000000For each bit the AND operator works like this
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
Edited by: Sven W. on Aug 30, 2010 5:45 PM

Similar Messages

  • Bitwise operator question...

    Hi,all.
    I have been using Java for around 1 year, but still not very comfortable with bitwise problems. I wish some one can give me a thorough explanation for these. Better yet, if you know how to use bitwise operator to solove the real programming problem, please post here too. I am doing some testing now. I will post some coding example later here, so you may help me on these coding too.
    Everyone have a great sunday night.

    Integers are represented by 32-bit values. You can have either 'signed' or 'unsigned' integer ranges.
    signed int 32000 to - 32000
    unsigned int 0 to 65000
    (note, these are approximations)
    For signed interpretations, the last digit on the left hand side represents wether or not the value is negative (called the most significant bit, msb).
    1000 0000
    The '1' is the msb
    Steps to convert -14 to its binary representation (using 2s complement as explained by above post):
    1. write the binary representation of '1' (ignore negative for now)
    2. invert the values
    3. add 1
    1) 0000 1110
    2) 1111 0001
    3) 1111 0010
    As you can see, the msb is a '1', so therefore it represents a negative value
    Note: In binary addition,
    1 + 1 = 0 carry 1
    1 + 0 = 1
    0 + 0 = 0
    As for other applications of this, I find myself using bitwise calculations in graphical work.
    As stated above (I love to reiterate others words, cause it's fun!!), Assembler language programming is a fantastic way to become an expert in the art of bitwise manipulation (if you have the patience).

  • How to make Bitwise operation in Labview ?

    Hello.. everyone,
    I need to make the bitwise operation (or) in Labview, but I can't find it somewhere!!!
    Anybody has the experiece about it, pls help me !!
    Thanks a lot

    Hi Nok,
    The standard OR function in the boolean sub palette of the functions palette performs a bitwise operation on it's input data. This is a polymorphic function so you can input scalar booleans, arrays of booleans or numerics.
    Hope this helps,
    Nick

  • Does bitwise operation on boolean datatypes work like logical operation ?

    Does bitwise operation on boolean datatypes work like logical operation ?
    For example, in the following code, how is each bitwise operation (say) 'b1 & b2' evaluated ?
    1) by converting the values of b1 (true) and b2 (false) to binary and doing '&' on them OR
    2) just treating it as a logical operation (i.e. similar to &&) where both have to be equal to be true
    Also, does the outcome of the if condition need to result in a 'true' or 'false' for the relevant message to print ? ....... Just fyi, I tried out this program and it goes to condition 2 but I do not understand why.
    class SSBool {
    public static void main(String[] args) {
    boolean b1 = true;
    boolean b2 = false;
    boolean b3 = true;
    if (b1 & b2 | b2 & b3 | b2)
    System.out.println ("condition 1");
    if (b1 & b2 | b2 & b3 | b2 | b1)
    System.out.println ("condition 2");
    Thank you,
    AG

    The Java Tutorial (always my first stop if I need an answer) says :
    "When both operands are boolean, the operator & performs the same operation as &&."
    That your program goes to condition 2 is obvious because the last test in the if-clause if (b1 & b2 | b2 & b3 | b2 | b1) looks at b1 which is true...

  • Logical bitwise operator

    Hi ALL
    Logical bitwise comparison operator 'O' is used between two operands say A and B as "A O B".
    A is of type INT1 and B is of type X.
    The above mentioned line was working fine till enabling unicode check. But now it says A should be of type X or Xstring.A's type cannot be changed since it is derived from a std structure.
    Is there some other operator which does the same function as operator 'O'?
    Regards,
    Navaneeth

    Hi,
    Check this..
    IF.....XOR.....
    Regards
    Vijay

  • Bitwise Operator ( ) help

    I'm a new beginner and I have some problems with such code:
    class Test {
         public static void main(String[] args) {
              int i = -1;
              int a = i;
              for ( int k = 0 ; k < 32 ; k ++ ) {
                   i = i >>> 1;
                   System.out.print(i+" ");
                   System.out.println(a >>> (k+1) );
    I hope that the two columns of the output wil be the same, but the
    last line isn't.
    Why a == -1 after " int a = -1; a = a >>> 32 " ? I think a should be 0.
    Am I right or is there any mistake?

    See the language spec:
    http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#5121
    in particular:
    If the promoted type of the left-hand operand is int, only the five lowest-order bits of the right-hand operand are used as the shift distance. It is as if the right-hand operand were subjected to a bitwise logical AND operator & (�15.22.1) with the mask value 0x1f. The shift distance actually used is therefore always in the range 0 to 31, inclusive.
    Though it doesn't say why.

  • BitWise Operations in java

    hi Guys
    Can any one help me out in explaining the below program
    public class Bitwise{
    public static void main (String[]args){
    int x=12&13;
    int y=x^6;
    System.out.println(y I 3)
    Pls help me with the above program in detail explanation
    Raghu

    Here's a better idea. You start by:
    1) adding print statements to print out x and y immediately after they're set.
    2) predicting what you think each print statement will produce, consulting your favorite text or tutorial (see below links) or the JLS if you need to.
    3) running the program.
    4) seeing if the results match what you expected.
    5) trying to figure why they didn't match, if they didn't.
    6) poting a specific question here about what you expected and why, and what you saw instead, if you're unable to figure it out.
    Installation Notes - JDK 5.0 Microsoft Windows (32-bit)
    Your First Cup of Java
    New to Java Center
    The Java&#8482; Tutorial - A practical guide for programmers
    The Java&#8482; Tutorial - Trail: Learning the Java Language
    Java Programming Notes - Fred Swartz
    How To Think Like A Computer Scientist
    Introduction to Computer Science using Java
    The Java Developers Almanac 1.4
    Object-Oriented Programming Concepts
    Object-oriented language basics
    Don't Fear the OOP
    Books:
    The Java Programming Language - 4th Edition
    Head First Java, by Bert Bates and Kathy Sierra
    Thinking in Java (Free online), by Bruce Eckel
    Core Java, by Cay Horstmann and Gary Cornell
    Effective Java, by Joshua Bloch
    http://java.sun.com/developer/Books/javaprogramming/
    Intermediate
    The Craftsman Series
    Java Design: Building Better Apps and Applets (2nd Edition)
    Head First Design Patterns

  • Using ModbusSlave and for bitwise operation

    I ran into a problem using a ModbusSlave to read a signed Integer for bitmasking.
    I connected the Tag value into D40001 and read the bits from ModbusSlave1.H40002.fx (for bits 0-15) and ModbusSlave1.H40001.fx (for bits 16-31).
    When the the MSB (Bit 15) was on, the number returned was a negative value, and the ModbusSlave showed no bits as set.
    I alos found this to be a problem using mod( int(WORD) , 2) --> to get Bit 0
                                                           mod( int(WORD/2) , 2) --> to get Bit 1...
    as this will return an error if WORD is negative.
    I saw a suggestion to check for the sign bit by: if ((WORD <0), TRUE, FALSE).
    How does this work if the sign bit is the only bit on (WORD = -0)?
    The solution we did was to create a new Tag in the PLC as a DINT (double INT-32 bit) and add a rung to move the INT(16 bit) into this new Tag.
    However I did find that this will be a problem if the MSB (bit 31) is used in the DINT.
    The getbit function worked but I was looking for a solution other than using this as I am often working from existing PLC's and don't always have access to the PLC program to make a change like this.

    Hello Khalid,
    The application is pretty simple.
    I am reading a tag from a AB Controllogix PLC.
    Lookout is seeing it as a 16 bit signed Integer.
    The tag has each bit assigned to a Photoeye or e-stop and I want to monitor each bit to see of it is true.
    It can be simulated using a Pot and ModbusSlave.
    I tried the "S" regsitered but did not see a value in the ModbusSlave1.H40002.fx.
    Should I use another connection?
    Dswift

  • How to convert bitwise operator for oracle

    hi all,
    Please help me to get convertion for (IP/16777216)&0xFF like
    If I have query select (IP/16777216)&0xFF I need IP address like 10 is there any way to do this
    Thanks in Advance
    Prashant

    Hi..
    Well not very clear with the question.
    If you want the ip you can use
    select utl_inaddr.get_host_address(Host_Name) from V$INSTANCE;
    If you want some conversion from decimal to hexadecimal you can refer to
    [http://arjudba.blogspot.com/2008/10/convert-decimal-to-hexadecimal-on.html]
    [http://www.jlcomp.demon.co.uk/faq/base_convert.html]
    Anand

  • Bitwise operator: (010|4)

    Executing the following code results in "12". I do not understand why?
    public class Test {
        public static void main(String[] args) {
            System.out.println(010|4);
    }From what I understand, the answer should be 6. What is wrong with my below logic?
    010 = 2
    100 = 4
    110 = 6
    Thanks!

    You can check out the JLS - go here:
    http://java.sun.com/docs/books/jls/second_edition/html/lexical.doc.html
    And look at section 3.10.1
    There's no way to explicitly enter a base 2 digit (that I know of) - you can specify it as base 16 by prepending with a 0x, or octal by prepending with a 0. You could use the Integer.parseInt(value, radix) method to do this by passing in the binary digit string and a radix of 2, as int value = Integer.parseInt("010", 2)I hope that helped
    Lee

  • Bitwise operations between int and char

    I need to do an xor of the following type:
    char c;
    short i;
    c = (char) (c ^ i);
    but i keep getting an "incompatable type" error.
    Any suggestions?

    The following code:
    public static void main(String[] args) {
        char c = '1';
        short i = 2;
        c = (char) (c ^ i);
        System.out.println(c);
    }compiled and ran - I couldn't use your code as-is because I needed to initialize c and i, but other than that it worked out for me.
    Sorry I couldn't help more
    Lee

  • SQL query for Bitwise operation via SSRS

    I am trying to write a query to display data in a SSRS report where we can select multiple values from a list parameter.
    The WHERE clause in the query has to filter based on the selected values with the statement below.
    I need to be able to pass each of the selected values from the SSRS report to replace the value
    1 below. I can get it to work if only one parameter value is selected, but not if multiples are selected.
    How do I get it to loop through each of the selected values and input that in to my where statement.
     where customer_communication_preferences & 1 <> 0
    Thanks in advance.

    I can pass the values across and use a function to split them out without an issue. Each time I try to run it as a stored procedure I can the error that:
    SP:
    CREATE Proc [dbo].[Get_CCP]
    (@MultiVal nvarchar(max))
    AS
    select customer_number,
    customer_communication_preferences
    FROM ts_customer
    WHERE customer_state = 'A'
    and (customer_communication_preferences & (SELECT Val from dbo.fn_String_To_Table(@MultiVal,',',1))) <> 0
    Then I do:
    Get_CCP'4096' --This works
    Get_CCP'4096,1024'  --This error with the error :
    Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.

  • Bitwise operations

    Hi..
    I need to evaluate a character (to be passed as block checking character for serial communication) which is formed by
    1. summation of all characters in message.
    2. setting the most significant bit to 0.
    How can i accomplish setting the most significant bit of this character to 0?
    Any help would be sincerely appreciated.
    Regards
    JS

    Use & operator

  • Please help explain these bitwise operations!

    I am working with a file that has a header with the size of the file encoded into 4 bytes like:
    >
    The ID3v2 tag size is encoded with four bytes where the most significant bit (bit 7) is set to zero in every byte, making a total of 28 bits. The zeroed bits are ignored, so a 257 bytes long tag is represented as $00 00 02 01.
    I have found someone's code that puts this together into the integer value, but i don't understand why they do each step. Is there anyone here who can explain this code to me?
    //Read in the bytes (why do they read char[] instead of byte[]?)
    char[] tagSize = br.ReadChars(4);    // I use this to read the bytes in from the file
    //Store the shifted bytes (why is it int[], not byte[]?)
    int[] bytes = new int[4];      // for bit shifting
    int size = 0;    // for the final number
    * Why are they combining these bytes in this way if they're
    * going to again combine them below (in the line setting "size")?
    //how do they know they only care about the rightmost bit on the 3rd byte?
    //how do they know to shift it 7 to the left?
    bytes[3] =  tagSize[3] | ((tagSize[2] & 1) << 7) ;
    //Why do they use 63 here (I know it's 111111)?
    //how do they know they only want the 3 rightmost of byte 2nd byte?
    //And how know to shift it 6 to the left?
    bytes[2] = ((tagSize[2] >> 1) & 63) | ((tagSize[1] & 3) << 6) ;
    bytes[1] = ((tagSize[1] >> 2) & 31) | ((tagSize[0] & 7) << 5) ;
    bytes[0] = ((tagSize[0] >> 3) & 15) ;
    //how do they know to shift these bytes the amount that they do to the left?
    size  = ((UInt64)bytes[3] | ((UInt64)bytes[2] << 8)  | ((UInt64)bytes[1] << 16) | ((UInt64)bytes[0] << 24)) ;

    6tr6tr wrote:
    You've GOT to be kidding! I posted only ONCE on THIS forum. Javaranch is owned by a different company and does NOT have all the same members that this web forum has. Posting the same question on completely different websites' forums is NOT cross-posting. Cross-posting is posting the same thing in different boards of ONE website's forums.Absolute rubbish. Here a couple of links for you:
    Wikipedia:
    [Crossposting is the act of posting the same message to multiple forums, mailing lists, or newsgroups.|http://en.wikipedia.org/wiki/Crossposting]
    JavaRanch's FAQ:
    [There might be times when you are inclined to post a question not only at JavaRanch, but also at some other site. When you do so, keep in mind that this is not generally in the interests of the posters who might be responding to your posts - those folks may find they've wasted their time. You certainly don't want to annoy those you want to help you, so you might want to make the experience as painless as possible.|http://faq.javaranch.com/java/BeForthrightWhenCrossPostingToOtherSites]
    Sun's FAQ, section C2:
    [Post once and in the right area: Multiple postings are discouraged, because they make the category lists longer and create more email traffic for developers who have placed watches on multiple categories. Because of this, duplicate posts are considered a waste of time and an annoyance to many community members, that is, the people who might help you.|http://wikis.sun.com/display/SunForums/Forums.sun.com+FAQ]

  • Confused about bitwise operations

    how do i get the right most bit of an integer?
    i have an integer value that counts from 0 to 31 and i am wanting to store each as a boolean array of 5 length.
    i.e.
    Int = 1 boolean array=00001
    Int = 31 boolean array=11111
    I have been trying to use >> which does seem to be working however i am not sure how to read only the last bit.
    Thanks

    thanks that works a treat.
    maybe i am going about this the wrong way, what i am trying to do is store the 5 right most bits of a number of integers and then store the resultant bits into a file.
    I thought i would make a bit array of the 5 bit representation of the 32 bit integers, however i cannot seem to write one bit at time to a file, so i am forced to manufacture byte repsentations of the bit array (every 8 bits encoded into a byte) before i can save the file.
    This seems a very convaluted way of doing it. I think it would be better to not use a bit array at all and just use bytes, however i am not sure how to so this.

Maybe you are looking for

  • Purpose of defining account group?

    purpose of defining account group?

  • Automatically converting spot colors to cmyk?

    I am working with Acrobat 6.0.2 Professional on a Mac. Is there a way to set Acrobat or Distiller to convert spot colors to cmyk automatically when converting Quark documents to PDF? I also use Badia PrintTools as a preflight check when saving the Qu

  • Keynote crashing every 2-3 minutes while typing

    Hello All, I'm going slighty nuts, because keynote (latest version and revisions) are crashing every 2-3 minutes while typing. I make presentations for a living and the situation is getting a litte precarious. So... I did the full monthy: uninstallat

  • Help in new tds rule

    Hii Experts, I have changed the new tds from gross to net amount.. but still the system is calculating on gross amount.. My right entry which should come Professional Fees Dr. 10000( posting key 40) Service tax Dr. 1236 (posting key 40) amount taken

  • Analytics Compatibility

    Hi, We are currently using Siebel 7.8 Insurance module and Siebel 7.8 Analytics. We are planning to upgrade just Siebel 8.0. application and keep the analytics intact (on the same version). Does anyone know if there is any compatibility issue with Si