operators

How to use binary operators (& or |) with mongodb in ruby on rails

Have you guys ever saved your information with binary masks to improve performance? This is my case and I am also using mongodb with rails to store and retrieve it. I've used a pair of scopes using '&' and '|' to retrieve users with specific roles, but each time I run those scopes I get all the users regardless the roles... how could I ...

== vs Equals in C#

What is the difference between the evaluation of == and Equals in C#? For Ex, if(x==x++)//Always returns true but if(x.Equals(x++))//Always returns false Edited: int x=0; int y=0; if(x.Equals(y++))// Returns True ...

c++ fraction class. overloading operators?

I am making a fraction class for a school project, and my brain is frying. I was told to overload the << and >> operators through the friend keyword. But I'm getting errors for this. I've posted the relevant code here: http://pastebin.com/NgCABGJ2 The errors include: error C2270: '<<' : modifiers not allowed on nonmember functions (thi...

How to do exponentiation in bash

I try echo 10**2 it prints 10**2. How to make it work? ...

AND, OR output wrong result

Suppose I use 2 AND and one OR to retrieve a result, first test with input text value on name, I could get correct result but when I change $getc to any value other than empty string, the result does not change, it only query name value. What is wrong? $query1 = "SELECT * FROM $tableName WHERE name LIKE '%$asd%' OR descriptions LIKE ...

Are there any standard or conventional graph operators?

The DOT markup language uses -> and -- to indicate directed and undirected edges between nodes. Do you know of any other programming or markup languages with graph operators, and are there any standards, conventions or even just trends for defining nodes and edges? ...

How a processor can calculate if A < B

This is probably a dumb question came to my mind, but I think I don't have answer to this - How processor would find if A < B? In fact there are other things as well like A>B or A==B. But if we solve A I understand that different processors may probably have different implementations but I wanted to have some high level idea of doing ...

What does '-a' do in Unix Shell scripting

What does -a mean in the below line. if [ "${FILE_SYSTEM}" != "xyz" -a "${FILE_SYSTEM}" != "abc" ] ...

Confusion about typeof

What is the typeof funtion? ...

Does the Java &= operator apply & or &&?

Assuming boolean a = false; I was wondering if doing: a &= b; is equivalent to a = a && b; //logical AND, a is false hence b is not evaluated. or on the other hand it means a = a & b; //Bitwise AND. Both a and b are evaluated. Thanks in advance. ...

Can someone please explain to me

.. the difference between the = and the == signs in Python? i.e provide examples when each is used so there's no confusion between the two? ...

Why is 3<<1 == 6 in python?

Possible Duplicate: Absolute Beginner's Guide to Bit Shifting? anyone can explain me that operator << or >> ...

how to write a function to implement an integer division algorithm without using the division operator in php.

How to write a function to implement an integer division algorithm without using the division operator. Floating point values and remainders may be discarded. Error conditions may be ignored. For example: f(10, 3) is 3 f(10, 5) is 2 f(55, 5) is 11 ...

What does >> do in java?

Okay, I tried looking up what >>, or shift means, but it's way over my head as this site explains it: http://www.janeg.ca/scjp/oper/shift.html So can someone explain it like they're talking to a kid? ...

can the safe bool idiom be implemented without having to derive from a safe_bool class?

Is there a trick to get the safe bool idiom completely working without having to derive from a class that does the actual implementation? With 'completely working', I mean the class having an operator allowing it to be tested as if it were a boolean but in a safe way: MyTestableClass a; MyOtherTestableClass b; //this has to work if( ...

Output is off in for loop

Okay, so I'm trying to learn how to use the % operator, and I made a simple program that prints out [0] in a loop, and every ten times it goes to the next line, but the first time it doesn't. this is the output: [0][0][0][0][0][0][0][0][0][0][0] [0][0][0][0][0][0][0][0][0][0] [0][0][0][0][0][0][0][0][0][0] [0][0][0][0][0][0][0][0][0][0...

Is it safe to use xor for variable swapping in PHP

Is it safe to use this kind of variable swapping in php ? $a^=$b^=$a^=$b; ...

Are >? or <? legitimate operators in any C++ dialect?

I ran across the following lines of C++ code in a file (non-contiguous lines) that gcc 4.2.1 won't accept: int frame = blk <? mBlkCnt-1; mInsCnt = blk <? mBlkCnt; mInsCnt = mInsCnt+1 <? mBlkCnt; const int to_read = (mFileSz-byte_off) <? mBlkSz; Both <? and >? are used in various places in the code. They appear to be a shorthand for as...

Why do different operators have different associativity?

I've got to the section on operators in The Ruby Programming Language, and it's made me think about operator associativity. This isn't a Ruby question by the way - it applies to all languages. I know that operators have to associate one way or the other, and I can see why in some cases one way would be preferable to the other, but I'm s...

Whats the difference between "<>" and "!="?

Normally I would use !=, then when I saw this sign <> it means not equal to as well. After that, I went to search on Google, what's the difference between <> and !=. But I could not find the answer. Anyone care to explain? Edit: Thanks for the answers guys =) ...