I was wondering if there was an efficient way to perform a shift right on an 8 bit binary value using only ALU Operators (NOT, OR, AND, XOR, ADD, SUB)
Example:
input: 00110101
output: 10011010
I have been able to implement a shift left by just adding the 8 bit binary value with itself since a shift left is equivalent to multiplying by 2.…
I've a few lines of code within a project, that I can't see the value of...
buffer[i] = (currentByte & 0x7F) | (currentByte & 0x80);
It reads the filebuffer from a file, stored as bytes, and then transfers then to buffer[i] as shown, but I can't understand what the overall purpose is, any ideas?
Thanks
I have a lot of code that performs bitwise operations on unsigned integers. I wrote my code with the assumption that those operations were on integers of fixed width without any padding bits. For example an array of 32 bit unsigned integers of which all 32 bits available for each integer.
I'm looking to make my code more portable and I'm…
Hello World!
I am facing a rather peculiar problem. I am working on a compiler for an architecture that doesn't support bitwise operations. However, it handles signed 16 bit integer arithmetics and I was wondering if it would be possible to implement bitwise operations using only:
Addition (c = a + b)
Subtraction (c = a - b)
Division (c…
While reading some documentation here, I came across this:
unsigned unitFlags = NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit;
NSDateComponents *comps = [gregorian components:unitFlags fromDate:date];
I have no idea how this works. I read up on the bitwiseoperators in C, but I do not understand how you can fit three (or…
I'm kind of new to VB.net, and since I just finished a C# course, the lack of parentheses creates a lot of confusion on how to write certain combinations of operators.
The C# equivalent of the line I am trying to reproduce in VB would be like this :
if ( (a == 0 && b != null) || (a == 1 && c != null) )
I'm have no idea…
I've recently read an interesting thread on the D newsgroup, which basically asks,
Given two signed integers a ∈ [amin, amax], b ∈ [bmin, bmax], what is the tightest interval of a | b?
I'm think if interval arithmetics can be applied on general bitwiseoperators (assuming infinite bits). The bitwise-NOT and shifts are trivial…
Given this example, how would I return the result of the equation rather than the equation itself as a string?
$operator = '+';
foreach($resultSet as $item){
$result = $item[$this->orderField] . $operator . 1;
echo $result;
}
Hi, I am pretty new to bitwiseoperators. Let's say I have 3 variables a, b and c, with these values in binary:
a = 0001
b = 0011
c = 1011
Now, I want to perform a bitwise AND like this:
a
AND b
AND c
--------
d = 0001
d &= a &= b &= c doesn't work (as I expected), but how can I do this?
Thanks
I was just wondering if there is an XOR logical operator in C (something like && for AND but for XOR). I know I can split an XOR into ANDs, NOTs and ORs but a simple XOR would be much better. Then it occurred to me that if I use the normal XOR bitwise operator between two conditions, it might just work. And for my tests it…
boost::operators automatically defines operators like + based on manual implementations like += which is very useful. To generate those operators for T, one inherits from boost::operators<T> as shown by the boost example:
class MyInt : boost::operators<MyInt>
I am familiar with the CRTP pattern, but I fail to see how…
I don't use C++ or bitwise operations at my current job but I'm thinking of applying to companies where it is a requirement to be fluent with them (on their tests anyway).
So my question is: Can anyone suggest a project which will require gaining a fluency in bitwise operations to complete?
On a side note, is there a canonical…
I'm not familiar with bitwiseoperators, but I have seem them used to store simple settings before.
I need to pass several on/off options to a function, and I'd like to use a single integer for this. How can I go about setting and reading these options?
I've been given the task of porting Java's Java.util.Random() to JavaScript, and I've run across a huge performance hit/inaccuracy using bitwiseoperators in Javascript on sufficiently large numbers. Some cursory research states that "bitwiseoperators in JavaScript are inherently slow," because internally it appears that…
How can I perform bitwise operations on strings in ruby?
I would like to do bitwise & a 4-byte string with a 4-byte long hex such as ("abcd" & 0xDA2DFFD3). I cannot get the byte values of the string. Thanks for your help.
I am using bitwise operations in order to represent many access control flags within one integer.
ADMIN_ACCESS = 1;
EDIT_ACCOUNT_ACCESS = 2;
EDIT_ORDER_ACCESS = 4;
var myAccess = 3; // ie: ( ADMIN_ACCESS | EDIT_ACCOUNT_ACCESS )
if ( myAccess & EDIT_ACCOUNT_ACCESS ) { // check for correct access
// allow for…
I am currently documenting all of Perl 5's operators (see the perlopref GitHub project) and I have decided to include Perl 5's pseudo-operators as well. To me, a pseudo-operator in Perl is anything that looks like an operator, but is really more than one operator or a some other piece of syntax. I have documented…
I've recently decided to undertake an SMS project for sending and receiving SMS though a mobile.
The data is sent in PDU format - I am required to change ASCII characters to 7 bit GSM alphabet characters. To do this I've come across several examples, such as http://www.dreamfabric.com/sms/hello.html
This example…
A bit of a philosophical question, I suppose. Hope it belongs here.
C language has the standard set of bit-wise operations, including OR, AND, XOR, SHIFT LEFT/RIGHT, NOT. Anyone has an idea why rotate left/rotate right isn't included in the language? These operators are of the same complexity as other bit-wise…
I'm interested in implementing a Forth system, just so I can get some experience building a simple VM and runtime.
When starting in Forth, one typically learns about the stack and its operators (DROP, DUP, SWAP, etc.) first, so it's natural to think of these as being among the primitive operators. But they're…
Hi,
Basically I was trying to replace the part of string with its actual value which comes immediately after oracle operators. I can do this for limited operators list like {=,,<} but I wonder that is there any way out to gather all the operators rather than giving them by hands? For instance, I have this…
How can i do a Bitwise OR on strings?
A:
10001
01010
------
11011
Why on strings?
The Bits can have length of 40-50.Maybe this could be problematic on int ?
Any Ideas ?