bit operator? For example, to solve a problem, it is very simple to use the bit operator.
bit operator? For example, to solve a problem, it is very simple to use the bit operator.
such as color value conversion, hexadecimal to rgb
function hexToRgb(hex){
var hex = hex.replace("-sharp","0x"),
r = hex >> 16,
g = hex >> 8 & 0xff,
b = hex & 0xff;
return "rgb("+r+","+g+","+b+")";
}
such as recording activity status and growth value. Use bit operations to give a variable multiple states
you can see this example; use bit operations to give a variable multiple states
A non-empty array with only one element appearing odd times and the rest even times. Find out which element:
int singleNumber(vector<int>& nums) {
return std::accumulate(nums.begin(), nums.end(), 0, [](int res, int n) {
res ^= n;
return res;
});
}
A non-empty array with only one element appearing once and the rest three times. Find out which element:
int singleNumber(vector<int>& nums) {
int twos = 0;
return std::accumulate(nums.begin(), nums.end(), 0, [&twos] (int ones, int n) {
ones ^= n & ~twos;
twos ^= n & ~ones;
return ones;
});
}
A non-empty array with only two elements appearing once and the rest twice. Find out which two elements:
vector<int> singleNumber(vector<int>& nums) {
int xr=nums[0];
for(int i=1;i<nums.size();iPP)
xr=xr^nums[i];
int pos=xr&~(xr-1);
int x=0,y=0;
for(int i=0;i<nums.size();iPP)
if((pos)&nums[i])
x=x^nums[i];
else
y=y^nums[i];
vector <int> res;
res.push_back(x);
res.push_back(y);
return res;
}
Carmack algorithm:
//
// x
//
float InvSqrt (float x)
{
float xhalf = 0.5f*x;
int i = *(int*)&x;
i = 0x5f3759df - (i >> 1); //
x = *(float*)&i;
x = x*(1.5f - xhalf*x*x); //
return x;
}
:
$exchange = function (){
$a = 19;
$b = 20;
$b = $a ^ $b;
$a = $b ^ $a;
$b = $a ^ $b;
echo $a.'-'.$b.PHP_EOL;
};
$exchange();
Previous: Does element-ui support script to import jsp?
Next: How to set different styles for labels according to the positive and negative numbers?
in order to ensure that the message is sent successfully, based on the principle of base , the message is sent in two steps: first, process the business logic and generate messages, which are stored in the library, which is a transaction. this tran...
if an array is defined in the smart contract, and the append method. So to read the latest value of this array, do you need to traverse the relevant transactions in the entire block chain and read out all the append (and possibly delete) to finally get t...
phenomenon: the service cannot be found using ElasticSearch as the storage method. There is no problem with using MySQL as the storage method before, and the service can be found quickly now the console does not report an error properties file...
I have pushed a project document to bitbucket on this side I have a test and a formal server suppose I want to push the test with me Synchronize git pull what should I do to implement it? I am commit and push then I presume to git pull. I need to ...
similar problems are also found on stockoverflow: https: stackoverflow.com questions 47807621 draw-emoji-on-bitmap-with-drawtextonpath my code is as follows: private Bitmap convertText2Bitmap(String text) { if (TextUtils.isEmpty(text)) ...
how to access an ethernet token to your own website for transactions such as Fire Coin, Yuan an, etc.? Check balance, transfer, etc.? What kind of process is it? ...
I know that message queues can cut the front and fill the valley message queue sharpening is easy to understand. Message queuing can limit traffic when a large number of requests are sent. Protect the back end. but how to understand filling grain ...
in the process of using rabbitmq, I now encounter a thorny problem, which is similar to multithreading, such as sending registration verification emails. I am now writing with the c-sharp console application, and I can only open multiple windows to enab...
all my files will be sent to bitbucket version control but how can I send a message to the channel I specified by slack after git push? ...
what is the relationship between BIP32 Extended Public Key and Pubic Key? Can you change it? for example: BIP32 Extended Public Key: xpub69RogXjzChBZoR8iyx4YoSgFcECGTDM8vV28YAnFHXYpNCxuphieARWjPk4Yd4EvPsugHAcgYS8E3o2fftsFaPVuMc6f48fRuhr7GkRQz3M P...
Application scenario: the client uploads the file and the django server writes a piece of status=1 data in the database. Then give it to rabbit to read the file and parse it. After parsing, set status to 2. The transmission format of rabbitmq is { "f...
recently, I have been studying the use of php+rabbitmq message queue for one-step message consumption. I want to install it in the local environment: Local Environment: windows+php+nginx+mysql find a lot of information on the Internet is based on apach...
when using php-amqplib to operate rabbitmq, it is found that basic_qos has three parameters prefetch_size prefetch_count global global and prefetch_count roughly understand the meaning of these two parameters but the meaning of the first parameter,...
the error message is as follows. What is the cause? secneo@localhost:~ tmp > sudo usr sbin rabbitmq-server RabbitMQ 3.6.1. Copyright (C) 2007-2016 Pivotal Software, Inc. -sharp-sharp-sharp-sharp Licensed under the MPL. See http: www.r...
because it seems that messages will be consumed according to priority only when consumers have unack. I feel that message priority is a very chicken-rib function. I don t know where it can be applied? ...
I have deployed RabbitMQ, on the private network server. Now I want the APP of android to receive the push of queue messages. What can I do? ...
< H2 > configuration file < H2 > rabbitmq-web < H2 > error log < H2 > java.net.SocketException: Socket Closed at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.8.0_171] at java.net.SocketInputStream.socketRead(SocketInputStr...
I am currently swinging between these two now it is more inclined to redis, because: redis can achieve the same queuing function as rabbitmq, and the two are tied redis also has an additional function to cache data do I understand this correctly...
I now have slack API and channel key I have been able to send messages to my designated channel on php , but what I want to implement now is when I send the bitbucket file git pull to my specified file in the server can I send a slack message to the c...
in RabbitMQ s go support library, there are two methods func (ch * Channel) Ack (tag uint64, multiple bool) error and func (d Delivery) Ack (multiple bool) error but do not understand the difference between these two methods? the description of ...