Bitand () function
Returns the result of the bitwise and operation of two numeric values.
Syntax
BITAND (nExpression1, nExpression2)
Parameters
NExpression1, nExpression2
Specify two values for the AND operation by bit. If nExpression1 AND nExpression2 are non-integer, they are converted to Integers before the AND operation by bit.
Return Value Type
Numeric type
Description
BITAND () compares each bit of nExpression1 with the corresponding bit of nExpression2. If the bits of nExpression1 and nExpression2 are both 1, the corresponding result bit is 1; otherwise, the corresponding result bit is 0.
The following table lists the results of the AND operation on nExpression1 AND nExpression2 by bit:
NExpression1 nExpression2 result bit
0 0 0
0 1 0
1 1 1
1 0 0
Bitand () function example
X = 5 & Binary 0101
Y = 6 & Binary 0110
? Bitand (x, y) & Return Value 4, binary is 0100
-----------------------------------------------------------------
BITOR and BITXOR in Oracle
In ORACLE, There is only BITAND and no BITOR, BITXOR
The reason is that with BITAND, it is easy to implement BITOR and BITXOR.
BITOR (x, y) = (x + y)-BITAND (x, y );
BITXOR (x, y) = BITOR (x, y)-BITAND (x, y) = (x + y)-BITAND (x, y) * 2;
Trunc () function
For the format and format of the TRUNC function, it is only accurate to the day, regardless of the number of months in a few years as long as it is the day, to determine a day of a month in a year, use trunc (date, ''dd '').
To put it bluntly, the format is year, accurate to ----- year.
For months, accurate to ------ year, month (no matter which year, as long as it is the same month and day)
Is the day, accurate to ------ year, month, day (regardless of which month, only care about the day)
1. TRUNC (for dates)
The date value intercepted by the TRUNC function for the specified element.
The syntax format is as follows:
TRUNC (date [, fmt])
Where:
Date: A date value.
Fmt date format, which is truncated by the specified Element format. Ignore it and it is intercepted by the latest date.
The usage of this function is as follows:
TRUNC (TO_DATE ('24-Nov-1999 pm ', 'dd-mon-yyyy hh: mi am '))
= '24-Nov-1999 12:00:00 am'
TRUNC (TO_DATE ('24-Nov-1999 08:00:00 pm ', 'dd-mon-yyyy hh: mi am', 'hh') = '24-Nov-1999 am'
When no format is specified for round (date, ''format''), if the time in the date is before noon, the time in the date is truncated to 12. m. (midnight, the beginning of a day), or enter the next day.
If format is not specified for TRUNC (date, ''format''), the date is cut to 12 A. M., and the condition before noon is not considered.
2. TRUNC (for number)
The TRUNC function returns the processed value. Its working mechanism is very similar to that of the ROUND function, except that the function does not ROUND or select the part before or after the specified decimal number.
The syntax format is as follows:
TRUNC (number [, decimals])
Where:
Number the value to be intercepted
Decimals indicates the number of digits after the decimal point to be retained. Optional. If this parameter is ignored, all decimal parts are truncated.
The usage of this function is as follows:
TRUNC (89.985, 2) = 89.98
TRUNC (89.985) = 89
TRUNC (89.985,-1) = 80
Note: The second parameter can be a negative number, indicating that the part after the specified number of digits on the left of the decimal point is truncated.