A
A
Askar Fuzaylov2016-09-27 12:51:32
PHP
Askar Fuzaylov, 2016-09-27 12:51:32

What is the bitwise operator used in Golang for the Not (~PHP) operation?

The bitwise NOT operator in PHP

~ $a / Not / Bits that are set in $a are not set, and vice versa.

Golang has ^ and &^ . Which one corresponds to the above operator in PHP?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
Ivanq, 2016-09-27
@ARACOOOL

It seems that there is no suitable operator, but there is xor - ^. It accepts two numbers (a and b, for simplicity). Where bit b is set to 0, bit a remains, if bit is set to one, the bit is reversed. It turns out that bit negation is an xor of numbers with a mask of ones.
I don’t know exactly, but it seems that the mask of units is m

A
Alexander Pavlyuk, 2016-09-27
@pav5000

To do a bitwise NOT operation on the variable b, you need to write
https://play.golang.org/p/Y9SrDSgNmf

O
Oleg Tsilyurik, 2016-09-27
@Olej

Go abstract

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question