What is a bitwise operation
Bitwise operators are operated in binary, which can only be used for integer-type operations. such as: Char,short,int,long
bitwise operators are used to get high and low values
int a=0x1234;
int high,low;
High = (a>>8) 0x00ff;
Low = A 0x00ff;
Left and right shift operators (
The left shift is a binary number, move a number o
Bitwise -AND Operator ()
Participate in the operation of the two data, press bits for "and" operation.Arithmetic Rules:00=0; 01=0; 10=0; 11=1;That is, the two-bit is "1" at the same time, the result is "1", otherwise 0For example: 35 is 0000 0011 0000 0101 = 0000 0001 Therefore, 35 is worth 1.
In addition, negative numbers participate in the bitwise AND operation in the complement form.
Special use:
A:
This article provides a detailed analysis of bitwise and or (^, amp;) in PHP, if you need a friend, refer to today's friends in the group who asked the question of bitwise and OR ..
I have been working in PHP for a year. maybe I am not familiar with this part. here I will introduce this part to new users.
Operations on binary data are mainly performed by location.
The code is as follows:
$ A = 1;$ B =
Logical operators:Logic and:Logical OR: | |Logical non-:!Note: Logic and logic or the use of short-circuit methods. From left to right, if the determined value is no longer evaluated.Eg:boolean c =1>2 2> (3/0); does not report abnormal errors, stating that no 3/0 is executed;Bitwise operators:~ Reverse: 0 to 1 1 to 0 Bitwise AND: 00 to 0, 01 to 0, 10 to 0, 11 to 1| bi
Today you see a piece of code in the project:if (~key.indexof (' I ')) { Pricetagdata.adulti = { tag:key, price:value}}I say to this operator is very strange, naturally also can not understand the author's intentions. Now that my curiosity is in a vigorous period, I decided to learn the usefulness of this operator.Looked at the eye ES5, originally it is the bit to take the counter-operator. The following is a description of the ES5 operator:
This article describes how to handle C # bitwise operations. The first step is to create an enumeration to indicate all permission management operations, followed by permission calculation.
This article describes how to handle C # bitwise operations. The first step is to create an enumeration to indicate all permission management operations, followed by permission calculation.
Common
Javascript bitwise left shift operator (
This article mainly introduces the Javascript bitwise left shift operator (
Bitwise left shift operator (
Left shift expression bit.
Result = expression1
Parameters
Result
Any variable.
Expression1
Any expression.
Expression2
Any expression.
Description
Var temp
Temp = 14
The value of the temp variable is 56,
Simple Application of enumeration, bitwise AND or operation, and displacement, and enumeration operation
When writing a program, we often encounter various settings, for example, set the dock status of the four sides of the window (for example, whether the top side is docked on the top of the parent control, whether the left side is docked on the left side of the parent control, and whether the right side is docked on the right side of the parent Cont
//Main.mLessonc12//Created by Zhang Yangji on 15-1-6.Copyright (c) 2015 Zhang Yangji. All rights reserved.//#import #define KdebugWhen a variable has a fixed number of values, you can define an enumeration typeEnumeration types declare a set of constants that establish a correspondence between a person's readable identifier and a number that a computer can read.If the enumeration type does not specify a constant, the default starts at 0, plus 1Enum season{Spring = 1,SummerAutumn = 4,Winter//};ty
C # bitwise operators , |, ^, We know that any information in the computer is saved in binary form. The bit operator is the logarithm.The bitwise operators in the C # language are
Unlike | or ^ Or ~ Complement
The complement operation only has one operand, while other bitwise operators both have two operands.The operand of the overflow
Writer:bysocket (mud and brick pulp carpenter)Weibo: BysocketWatercress: BysocketFacebook:bysocketTwitter:bysocketMasons like Java, and the article always pulls Java. I/O basis is the binary, which is the Bit.Bit vs. binaryWhat is a bit (bit)? Bit is the unit of CPU processing or the smallest data storage. It is similar to a small, small switch that is opened and closed, and is expressed as 1 or 0. So this is the "cell" in which the computer processes any data, so keep in mind.The binary system
4.1.2 Bitwise operators and | Operators also have a role in performing operations on numeric values. When used in this way, they deal with a series of bits stored in a variable, rather than variable values, so they are called bitwise operators.Let's discuss and | below. The operator each bit in the first operand is compared to a bit in the same position in the second operand, and in the resulting result,
Bitwise operators are:The following experiments are done to learn these kinds of operationsThe following data types are int with 32 bit representation, binary right 0 omittedBinary representation of 21 and-21System.out.println (Integer.tobinarystring (21)); 10101System.out.println (Integer.tobinarystring (-21)); 11111111111111111111111111101011 System.out.println ("System.out.println (" -21 -21 >> sign bit to the left high fill sign bit move n bits d
not given in the class declaration, when f is defined outside the class,Void A: f () indicates that the f () function is A member function of Class.
(2) It is used directly before the global function to indicate that it is a global function.For example, in VC, you can add ::
(3) Reference member functions and variables, and scope member operators
For example, System: Math: Sqrt () is equivalent to System. Math. Sqrt ()
3. c/c ++ bitwise domain struc
One, the binary1. What is a binary* is a way of counting, the representation of a numeric value2. Binary* Features: only 0 and 1, every 2 into 1 * Writing format:0b or 0b start * Application: Binary instruction \ binary file, variable in memory is binary storage 3. octal * Features:0~ 8 in 1 * Writing format:0 start 4. hex * Features:0~f, 1 in every * Writing format:0x or 0x start Second, bitwise operations1. Press at 1> featu
1. Bitwise AND operator ()Since any one is the result of the 0, operation, it is 0, so you can use this operator to set the unnecessary bits in the variable to 0. The method is to create a ' mask ' and then use to combine it with the original variable. such as: Letter=letter 0x0F;2. Bitwise OR operator (|)One of the two bits is the result of the 1,or operation is 1, so the result of these two variables is
It becomes easy to understand the processing of these two permissions, as long as the user's current total permission value and the permissions required for the current operation are bitwise and computed each time a permission operation is executed. If the result is true, you can handle false errors. (of course, you can design a program without permission) first, we define four constants to set four permissions:
=======================================
1. Not
Bit operators not from ~ The essence of the. Not operator is to calculate a negative number and then subtract 1.
The bitwise operator not is a three-step process.
A. Convert the operator to a 32-bit number.
B. Convert the binary form into its binary anticode
C. Convert the binary back code to a floating point number.
Example:
VaR num = 10; document. Write (~ Num );
Result:
-11
2. and
Now there's a bunch of numbers,
$str =1300022332121
Ask for a bitwise to reverse how to get
This bitwise counter, and the other program's bitwise reverse, there is a difference?
Because I'm going to be able to pass him to C + + writing program,
Please teach the Heroes
Reply to discussion (solution)
$str =1300022332121;echo ~ $str; 2147483647
PHP
I. background
In work, the database used is MySQL, the project uses Java, and the JPA technology is used. Hibernate is used at the underlying layer. Some projects need to perform bitwise AND operations, but the hql language does not support it. This article describes how to enable our program to support bitwise AND operations.
II. Implementation
Preferred sqlfunction interface implementation
Package
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.