битовые-операции

How to count the number of bits in one byte in assembly language?

Hello. I can't figure out how to count the number of bits in one byte using the bit mask and the logical operations AND, OR, ... untouched. But how, using a mask, can you count the number of units in a number consisting of 8 bits (for example, 00011001)?

Bits in C++ on the example code.

People help out there is nothing in the Internet about bits on C++, or else they are called bit fields. The code is there, bu ... ugh 32 characters) but for what. Well, in general, this fragment is generally stupid. I don't understand help me understand.

Bitwise operations - which ones are useful for programmers of "higher" levels to know about?

Hello! I ask this question more for self-education than out of a real momentary need: What do "higher-level" programmers ne ... of a number without a comparison operation Do bitwise operators (other than shifts) make any mathematical sense in base-10?

Why do we need bitwise operators and what do they actually do in C?

Hello! Please explain why bitwise operators are needed and what is the principle of their operation? I've already reread the ... veral times and read it online, but I don't understand them. If possible, with practical examples. Thanks for understanding.

Difference of binary numbers

Hello. I made a bitwise addition of binary numbers, but how to make the difference between two binary numbers, namely, when t ... hen at the end there is no one to borrow from. I need the answer to be negative. I don't understand how this can be arranged.

Arrays of bit fields in C

Regarding the structure with bit fields, I have seen this phrase: it is unacceptable to create arrays of bit fields, bit fiel ... to imagine an array of instances of a single structure field. Or is it that bit fields cannot themselves have an array type?

c++ operator overloading

I am writing a class for a matrix with such functions: inverse(A^-1) sum(+) difference(-) product(*) When I run the progr ... } return (m); } ... c=a.inverse(a); But it outputs this: ... inverse of matrix A: 1 0 0 1 Segmentation fault

Bitwise shift in C

I recently started studying C. Naturally, I could not pass by the program for converting from the n-th number system to the x ... he two lines shown below. Explain in more detail how these two functions work lines. result <<= 1; result += c - '0';

Bitwise comparison of Python characters

It is necessary to calculate the bit difference of characters in python. I.e., roughly speaking, the character " a "and the ... ance, only between characters and the difference between characters will be equal to the difference of the sum of their bits.

Bitwise And in C#

I need to translate a similar line of code - if (a & b) { } Where a is an int, b is a number from enum. In C++, there is a "bitwise And"operator. Is it possible to do this in C#?

What other fundamentally different ways of implementing the min and max functions do you know?

To prepare a video lecture on the min and max functions, I would like to learn from the community about fundamentally differe ... similar ones (otherwise, you can add a dozen more formulas), namely, by the idea itself? That's what I'm asking you to share.

bitwise shifts

Task condition: Implement the flipBit method, which changes the value of one bit of a given integer to the opposite.Let's ... (1 << bitIndex-1); } Question: I can't understand what is happening here: (1 << bitIndex-1) Explain pozh-a.

Packing standard bytes (8 bits) into 6 bits

The input is a file (it doesn't matter which one). I need to pack 8-bit bytes to 6-bit bytes. That is, we received 3 8-bit b ... have already come from another byte, and the mask becomes this (11110000). I don't need the code, I just want the algorithm.

What is the difference between "& & "between" & " and "| | "between" | " java?

Read the book the philosophy of Java. got to the point: what is the difference between single and double use of sivvols boo ... if(a|i){} if(a&&i){} if(a&i){} Except that & it should beat two true, and with |, you only need one true.

Bitwise shift to the left, a problem

I rewrite some code from javascript to pcp, it should work identically. If you have dealt with bitwise OR, javascript compar ... unctions | << >>>, and then found a ready-made library https://github.com/simaguo/javascript-bitwise-operators

Command line and bit operations in C

There is a code. How to run it via the command line, as it is done in general. The program itself must swap the two specified ... ; //и заполнили нужными значениями z = z | (bx << (8 * y)) | (by << (8 * x)); printf("%llx\n", z); }

How does the bitwise XOR operator work in JavaScript?

Why is it that after 11100, 420 pops up instead of 00100, but the final value (11000) still matches the original one? var sir = 11000; alert(sir); var meg = 11100; alert(meg); var tun = sir ^ meg; alert(tun); alert(tun ^ meg);

Don't understand Python bit operations & |

I don't understand what bit operations do with a number like & and | 5 & 3 gives 1, and 5 | 3 gives 7. I thought it ... ~5 gives -6. And here everything is immediately clear, then on bit and and OR there is no clear answer in simple words.

How does the xor operator work?

For example, there is a task to find a unique value in an array: a = [1, 2, 3, 4, 5, 1, 2, 3, 4] You can do: a.inject(: ... then (3^3) returns 0. It would be interesting to know and fundamentally (how to apply XOR) and how it works in my example.