operators

What does (a+b) >>1 mean?

What does int c = (a+b) >>1 mean in C++? ...

Howto compute the factorial of x

how to get the value of an integer x, indicated by x!, it is the product of the numbers 1 to x. Example: 5! 1x2x3x4x5 = 120. int a , b = 1, c = 1, d = 1; printf("geheel getal x = "); scanf("%d", &a); printf("%d! = ", a); for(b = 1; b <= a; b++) { printf("%d x ", c); c++; d = d*a; } printf(" = %d", d); ...

Why typeof is called operator instead of function?

While reading this article (Special Operators) in MDC, I got a question like why typeof, new, etc. are called operators? I have a conception say + is a operator because it operators on two entities like 2+3 and gives another value. Ofcourse functions also operates on say two entities like the same way. Then what is difference? Th...

Where are operators defined (in C#)?

Just wondering where the rules for operators in C# are actually defined. E.g. where can I see the code which says that == checks the references of two objects? I can see the operator overloads in e.g. the String class but now i'm interested in seeing the 'base' case. Is it just something that the compiler explicitly knows what to do ...

Simple Operator question. +=

So my friend gave me some source code to start out with so I could review and understand it and I have a question about it, but since he's not online I thought I would try here, mainly I don't quite understand this line. num += i; Essentially, this is the same as num = num + i right? If you need more details please tell me! I l...

What does the @ character do in jQuery?

On the selectors page, it says @ is one of the meta-characters. But what does it do? ...

Strange behaviour of ++ operator in PHP 5.3

Watch following code: $a = 'Test'; echo ++$a; This will output: Tesu Question is, why ? I know "u" is after "t", but why it doesn't print "1" ??? EDIT: Becouse Zend books teach following: Also, the variable being incremented or decremented will be converted to the appropriate numeric data type—thus, the following code w...

Ambiguous template error adding std::string to uint in Visual C++

I'm getting the following error when I compile the following code on Visual Studio 2008 / Windows SDK 7 const UINT a_uint; UINT result; throw std::runtime_error( std::string("we did ") + a_uint + " and got " + result ); Ironically, I ended up with this result: error C2782: 'std::basic_string<_Elem,_Traits,...

While loop, doesn't seem to do anything?

Hi there i'm trying to make a function in C++ that takes a number, i, and decides if it is a prime number or not by running through a loop to find it's multiples, and then makes sure it isn't prime through a series of test. However, it seems the loop isn't even being run through. I've told it to output no matter where in the loop it is, ...

Why is `print (52-80)*42` different than `print 42*(52-80)` in Perl?

PERL:: What is: (52-80)*42 42*(52-80)? Ans: 1) -28 2) -1176. Why? Have fun explaining/justifying this please! #!/usr/bin/perl use strict; print 42*(52-80) , "\n"; print ((52-80)*42) , "\n"; print (52-80)*42 , "\n"; print "\n"; my $i=(52-80)*42; print $i, "\n"; Output: > -1176 > -1176-28 > -1176 ...

C++ operators question

Given that x = 2, y = 1, and z = 0, what will the following statement display? printf("answer = %d\n", (x || !y && z)); it was on a quiz and i got it wrong, i dont remember my professor covering this, someone enlighten me please... i know the answer i get is 1, but why? thnx ...

event delegate (in)equality ?

Could someone explain the meaning of the following portion of code : private event UserChangedHandler m_UserChanged; public event UserChangedHandler UserChanged { add { if (m_UserChanged != value) { m_UserChanged += value; } } } thanks ...

What does ?? operator means in C#?

Possible Duplicate: What do two question marks together mean in C#? Hi, I was looking for some trainings of MVC 2 in C# and I found this sintax: ViewData["something"] = something ?? true; So, what is that '??' means ?. ...

Why does this go into an infinite loop?

Hi, I'm a teacher, and yesterday a student wrote the following code: public class Tests { public static void main(String[] args) throws Exception { int x = 0; while(x<3) { x = x++; System.out.println(x); } } } we know he should have writen just x++ or x=x+1, but on x = x++; it s...

operator overloading in c++ ( with and without friend )

Hey, I would like to know the difference between these 2 operator definitions: 1: class Rational{ //... public: //... Rational operator -() const{ return Rational(-t,b);} //... }; 2: class Rational{ //... public: //... friend Rational operator -(const Rational& v) {return Rational(-t,b);} //... }; as far as i understand, for the u...

what is the difference between - and NOT operator in Lucene?

In the query syntax of Lucene it is said the following: The NOT operator excludes documents that contain the term after NOT. ... The "-" or prohibit operator excludes documents that contain the term after the "-" symbol I think the difference is that the - operator can be used alone, which is not the case for NOT. Is that it? ...

null instead of ==

I have just started to learn Haskell out of interest. I follow learnyouahaskell.com. There I found this: null checks if a list is empty. If it is, it returns True, otherwise it returns False. Use this function instead of xs == [] (if you have a list called xs) Why is that? Why should we use null instead of == when both pro...

Where can one find a list of operator overloads?

Where can one find a list of the function signatures for all operator overloads? ...

php calculations and echoing?

i have this function that takes two values and displays them, but its not doing the calculation right? php code: formatVote($votes_up,$votes_down) $net_vote = $votes_up - $votes_down; return <<<ENDOFRETURN <strong>$net_vote</strong> ENDOFRETURN; html page: <?php //rows retrieved from database.... formatVote($row['votes_up'],$...

Chaining operator functions in Python's filter

I have a list of objects and want to filter them according to some criteria. I can do it with list comprehension: import datetime, pytz # let's have a range of 100 hourly datetimes (just an example!): dates = [ datetime.datetime(2010, 10, 1, 0, 0, 0, 0, pytz.utc) + datetime.timedelta(hours=i) for i in xrange(100) ] # now I want a list ...