operators

Python - '>>' operator

What does the >> operator do? For example 10 >> 1 = 5 Thanks ...

What is '\0' in C++?

I'm trying to translate a huge project from C++ to Delphi and I'm finalizing the translation. One of the things I left is the '\0' monster. if (*asmcmd=='\0' || *asmcmd==';') where asmcmd is char*. I know that \0 marks the end of array type in C++, but I need to know it as a byte. Is it 0? In other words, would the code below be the...

Understanding the bitwise AND Operator

Hello, I have been reading about bit operators in Objective-C in Kochan's book, "Programming in Objective-C". I am VERY confused about this part, although I have really understood most everything else presented to me thus far. Here is a quote from the book: The Bitwise AND Operator Bitwise ANDing is frequently used for masking operat...

question about % operator in C++

i have following code #include <iostream> #include<exception> #include <cstdlib> int main(){ for (int i=0;i<100;i++){ std::cout<<i<<" "; if (i %5==0){ abort(); } } return 0; } but it only writes 0 and says that abort was called why?i think it should ouput 0 1 2 3 4 and than...

Ruby Overriding Operator

I have a class like this: class MyObject cattr_accessor :value_ def +(right_) self.value_ + right_.value_ end end I want to be able to do something like this: x = MyObject.new y = MyObject.new x.value_ = 1 y.value_ = 2 puts x + y It's not working though. Not the cattr_accessor as opposed to attr_accessor, not sure if t...

why is the output different in case of &&, &, ||

Here is the code segments Can you explain why outputs are varying 1) public static ShortCkt { public static void main(String args[]) { int i = 0; boolean t = true; boolean f = false, b; b = (t && ((i++) == 0)); b = (f && ((i+=2) > 0)); System.out.println(i); } } output in...

What's could be the right test case for evaluating assignement operators performance vs concrete operations?

Simply I am trying to figure out what is the fast way to assign a value like somevar+=1; or somevar=somevar+1; time ago in situations with text instead of integers I encountered some performance decrease using text+="sometext" instead of text.append("sometext") or text=text+"sometext", the problem is that I did not find anymore the...

Difference between tertiary and ternary ?

It is my understanding that, the conditional operator ( condition ? consequence : alternative ) is often referred to as both the “tertiary operator” and the “ternary operator”. What is the difference between these terms? ...

What's needed to handle annotation viewing in a PDF?

Hey everyone, I am working on parsing the PDF content stream to be able to read and handle annotation operators and also to add these. Can anyone shed some light on how to go about doing this, without using a prebuilt library? I understand it is a daunting exercise, but any pointers would be appreciated. Note: I've read a fair amount of...

Python + and * operators.

Hello, I'm working my way through some code examples and I stumbled upon this: endings = ['st', 'nd', 'rd'] + 17 * ['th'] + ['st', 'nd', 'rd'] + 7 * ['th'] + ['st'] I understand that for numbers after 4 and until 20 they end in 'th' and I can see that we are adding 17 more items to the list, and I understand that '17 * ['th'] is addi...

Logical operators question: (A>=100 && B<100 || B<A)

Hi, is the expression alright? (A>=100 && B<100 || B<A) I am not sure whether there should not be: (A>=100 && (B<100 || B<A)) I need to say that when A>=100 AND (B<100 OR B < A). ...

Fake array slicing operator: Make it shorter

Is there some innovative way to make the "print" shorter without too much confusion? And which of the "print" do you like most? define('_','_'); function _j($a, $b) { return $a._.$b; } // Output 0_0 print (0)._.(0); print _j(0,0); Update What I want to do is to have slice syntax that are in Python/Ruby into PHP eg. a[1:3] a[1,3...

Cant figure out operators in php statement

I need to edit a function, but I cant figure out what the ? and the : false mean in the return statement. I think the : is an OR but the ? I dont know. public function hasPermission($name) { return $this->getVjGuardADUser() ? $this->getVjGuardADUser()->hasPermission($name) : false; } Anyone that can clear this up for me? ...

How to check if a list have any different value

Hello, I have a table like the following: (date1, date2, date3, date4, date5) and I want to check if ANY of these dates is different than any other. The trivial solution is: WHERE date1 <> date2 OR date1 <> date3 OR date1 <> date4 OR date1 <> date5 OR date2 <> date3 OR date2 <> date4 OR date2 <> date5 OR date3 <>...

What does ">>" operator in C# do?

I ran into this statement in a piece of code: Int32 medianIndex = colorList.Count >> 1; colorList is a list of class System.Drawing.Color. Now the statement is supposed to retrieve the median index of the list .. like the half point of it .. but I can't understand how that >> symbol works and how the "1" is supposed to give the media...

F#: explicit type parameters in operator binding

I'm trying to define operator with the explicit type parameters and constraints: let inline (===)<'a, 'b when 'a : not struct and 'b : not struct> a b = obj.ReferenceEquals (a,b) It works well in F# 2.0, but produces the: warning FS1189: Type parameters must be placed directly adjacent to the type name, e.g. "type C<'...

java == operator

Possible Duplicate: Weird Java Boxing Hi, Can somebody explain why the last print returns false ? int a = 100; int b = 100; System.out.println(a == b); // prints true Integer aa = 100; Integer bb = 100; System.out.println(aa == bb); // prints true Integer aaa = 1000; Integer bbb = 1000; System.out.println(aaa == bbb); /...

Scheme: why this result when redefining a predefined operator?

I received an unexpected result when redefining the + operator in a scheme program using guile. I should point out that this occurred while experimenting to try to understand the language; there's no attempt here to write a useful program. Here's the code: (define (f a b) 4) (define (show) (display (+ 2 2)) (display ",") (display (f...

what does this PHP operator =& means?

Possible Duplicate: what do =& / &= operators in php mean? I found this operator "=&" in the following code, and I do not know what it means. Could someone explain what it means and does? THE CODE WHERE I READ IT: function ContentParseRoute($segments) { $vars = array(); //Get the active menu item $menu =& JSite...

Fooling Ruby's case operator, ===, with proxy objects

I'm trying to make a proxy object that transfers almost all method calls to a child object, essentially the delegator pattern. For the most part, I'm just using a BasicObject and passing every call with method_missing to the child object. So far, so good. The trick is that try as I might, I can't fool Ruby's case operator, so I can't ...