Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why am I getting 2 instead of 3 when I perform BIT_OR(2,1)?

SELECT UTL_RAW.CAST_TO_NUMBER (              --> decimal: 3? nope, 2
            UTL_RAW.BIT_OR(                  --> binary: 11? shouldn't it?
                UTL_RAW.CAST_FROM_NUMBER(2), --> binary: 10
                UTL_RAW.CAST_FROM_NUMBER(1)  --> binary:  1
share|improve this question

CAST_FROM_NUMBER returns RAW; if you check result of UTL_RAW.CAST_FROM_NUMBER(2) , it's not 2 but "C103" (which I believe means (03-1)* pow(10,(0xC1-0xC1))) . You need something like



Some links about internal number representations: ,
Your code returns result of C103(internal representation of 2) & C102(internal representation of 1) which is 2

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.