The binary-operators tag has no wiki summary.
16
votes
2answers
263 views
Playing with references
I can see why
$a = new ArrayObject();
$a['ID'] = 42;
$b = &$a['ID'];
$c = $a;
$c['ID'] = 37;
echo $a['ID']."\n";
echo $b."\n";
echo $c['ID']."\n";
outputs 37, 42, 37
while
$a = new ...
3
votes
1answer
51 views
Unary Operations fused with assignment
Doubtful result in the following code:
public static void main (String[] args)
{
int i = 2;
i = i+=2 + i++;
System.out.println(i); }
Was expecting 8 as output, as 'i+=2' should update i, but its ...
0
votes
0answers
44 views
Efficient modulus division by a fixed divisor (using only primitive binary operands)
I have an 8-bit microcontroller that does have an integer multiplication unit, but does NOT have a hardware division or modulus instruction.
What I need to do is to perform modulus division for a ...
1
vote
3answers
54 views
Bash null binary operators
A recent test I took had a question on the output of the following bash command:
var=; [ -n $var ]; echo $?; [ -z $var ]; echo $?
The results are 0 and 0, indicating the return codes for both unary ...
2
votes
3answers
235 views
C++ matrix class overloaded operators returning by reference
I'm writing templated matrix class, and I get stack overflows when returning by value from operators: +,-,* for larger matrices. I would prefer to somehow return by reference to relieve the stack and ...
2
votes
1answer
78 views
type promotion in C and type casting
I have the following variables:
UWORD64 length;
UWORD32 thumbnail_offset;
UWORD32 thumbnail_length;
UWORD64 sum;
And this is what I want to do:
sum = (UWORD64)(thumbnail_offset + ...
2
votes
1answer
100 views
how to find the longest zero sequence in binary form of integer in assembly?
how to find the longest zero sequence in binary form of integer in assembly?
I can use shift, or, xor, nor and other logical operations. I can find the sequence of ones in such algorithm:
1) Shift
2) ...
-1
votes
1answer
142 views
C++ compilation error using unary und binary function objets
I have a short question regarding a shot C++ code snippet. I get a compilation error, as soon as i want to evaluate the () operator (last line before return of 0 in the main method). The code looks ...
1
vote
3answers
760 views
C reverse binary [duplicate]
Possible Duplicate:
C reverse bits in unsigned integer
How can I reverse a binary number only using binary operators?
E.g:
11100000 -> 00000111
00110100 -> 00101100
00111111 -> ...
0
votes
1answer
87 views
Custom class comparison needed for binary_search()
I have a custom class and std::vector filled with objects of this class. And I want to do binary_search in this array.
I've overloaded operators on my class like this:
bool operator ==(const ...
0
votes
1answer
324 views
When converting from infix to postfix, how do you specify between a uniary and a binary +/-
Under this grammar:
^ + - * / < > = <= >= and or not
I'm using a function (shunting-yard algorithm) to convert from infix to postfix and it works! Except it doesn't include ...
2
votes
1answer
433 views
Unary And Binary Minus in Parse Tree
I am creating a parse tree that will contain expressions similar to
3 - 4 * 8
or
8 * -5
or
-(10 * 1)
I need a way to distinguish between the unary and binary minus. The way my grammar is ...
0
votes
4answers
121 views
can't assign iterator to constant input vector in a binary function
I am trying to write a binary function that takes two vectors(of the same length) and adds them by value. For some reason the following code does not work:
struct Plusval : binary_function ...
0
votes
0answers
85 views
fractional binary subtraction
I am having difficulty understanding why the following binary subtraction gives the result that it does. I keep getting a different answer. I am trying to compute 0.1-x such that x is ...
1
vote
3answers
412 views
Integer constant is too large for its type AND invalid operands to binary operators
I'm using double long in my 64 bit computer and sizeof(double long) is 16 bytes.
So I do the following assignment:
long double f = 0xA0000000000000000000000000000000; // 32 characters in hex
and ...