operators

Difference between | and || or & and && for comparison

Possible Duplicate: A clear, laymans explanation of the difference between | and || in c# ? What is the difference between comparing with | and || or & and && in C# and Javascript? Examples: if(test == test1 | test1 == test2) or if(test == test1 || test1 == test2) if(test == test1 & test1 == test2) or if(test == test1 && test1...

how to refer to the current struct in an overloaded operator?

Hi! I have a struct for which i want to define a relative order by defining < , > , <= and >= operators. actually in my order there won't be any equality, so if one struct is not smaller than another, it's automatically larger. I defined the first operator like this: struct MyStruct{ ... ... bool operator < (const MyStruct &b) const ...

How do I build up LINQ dynamically

I have a scenario where I have custom configured column names, associated operators like < > = between etc. and then a value associated. I'm trying to determine if it is possible to build up a LINQ query with a dynamic (string) where clause? I've noticed the Predicate.OR Preditcate.AND stuff, but that is not quite what I'm talking abou...

How to treat nulls in equality comparisons?

When I have to implement equality comparers for public class SampleClass { public int Prop { get; set; } } Should I make null == new SampleClass() and new SampleClass() == null and new SampleClass().Equals(null) false? And what about new SampleClass() != null Should it be also false? UPDATE People are questioning th...

Overloading friend operator << for template class

I'm trying to overload the operator << as a friend to a template class Pair, but I keep getting a compiler warning saying friend declaration std::ostream& operator<<(ostream& out, Pair<T,U>& v) declares a non template function for this code: friend ostream& operator<<(ostream&, Pair<T,U>&); it gives a second warning as a recommenda...

What does !== in php mean ?

I saw if($output !== false){ } It almost works like not equal. Does it has any extra significance? ...

How can I read from an std::istream (using operator>>)?

How can I read from an std::istream using operator>>? I tried the following: void foo(const std::istream& in) { std::string tmp; while(in >> tmp) { std::cout << tmp; } } But it gives an error: error: no match for 'operator>>' in 'in >> tmp' ...

Rounding down DECIMAL(14,3) to third decimal digit in SQL 2008

I have to round down all incoming data with type DECIMAL(14,3) which has 3 decimal digit to the last one. I.e.: 100; 100.0; 100.00; 100.000 -> 100 100.2; 100.02; 100.20; 100.22 -> 100.xx but 100.221 -> 100.22 100.229 -> 100.22 Using which SQL operator can I check that residue of division in decimal digit is greater then zero? ...

What does the /= operator in C# do?

What does the /= operator in C# do and when is it used? ...

Custom datatype operators in Sql Server?

In Sql Server 2008, they added new DATE and TIME datatypes, complimenting DATETIME. I wanted to combine a DATE and a TIME to a DATETIME, and thought maybe the obvious would work, and I could do SELECT DATEFLD + TIMEFLD FROM MYTABLE and DATE + TIME would return the corresponding DATETIME. Unfortunately, that's a little too obvious, a...

XAML 'NOT' operator?

<Button IsEnabled="{Binding (Not IsDisabled)}" /> Is there a way to do it with pure xaml, or I will have to do it via code? PS. I asked the question knowing that I can create a boolean converter like this: <ValueConversion(GetType(Boolean), GetType(Boolean))> Public Class BooleanFlagSwitchConverter : Implements IValueConverter ...

System.Nullable<T> What is the value of null * int value?

Consider the following statements: int? v1 = null; int? v2 = 5 * v1; What is the value of v2? (null or empty string?) How can I prevent the compiler to mark it as invalid operation? Do I need to follow custom exception handling? ...

Applying operators to non-mathematical objects?

I'm curious about how some operators work (+, -) in terms of objects. I've always wondered how EventHandlers work by adding a method: Foo.Action += new FooActionHandler If not an Event, what about returning a comparison? DateTime - DateTime That returns a TimeSpan object, and I'm a bit baffled as to how that's possible. I use t...

Is it possible to override the array access operator for pointers to an object in C++?

I'm trying to do some refactoring of code, and have run into a problem. The program has a data manager that returns pointers to arrays of structures as a void*. One of the new types of data, instead of having a single pointer to an array of structures, has two pointers to arrays of numbers. The problem is that all the processing code ...

How do I overload an operator for an enumeration in C#?

I have an enumerated type that I would like to define the >, <, >=, and <= operators for. I know that these operators are implictly created on the basis of the enumerated type (as per the documentation) but I would like to explictly define these operators (for clarity, for control, to know how to do it, etc...) I was hoping I could do ...

Where can one find a list of all the operators in J

I am trying to learn J and one huge problem I'm running into is I don't know what all the predefined operators are or where to find them. It took me way too long to figure out the | is both the remainder function(when it dyadic) but when its used monadic it gets absolute value or magnitude. Does any one know where a list of all the ope...

what do "=&" / "&=" operators in php mean?

what do "=&" / "&=" operators in php mean? where can I read info about them? searching google doesn't help ...

When is the spaceship operator used outside a sort?

This is a best practice question. I've only seen the Perl spaceship operator (<=>) used in numeric sort routines. But it seems useful in other situations. I just can't think of a practical use. Can anyone give me an example of when it could be used outside of a Perl sort? ...

What does the & symbol mean in Objective-C?

What does the & symbol mean in Objective-C? I am currently looking at data constucts and am getting really confused by it. I have looked around the web for it but have not found an answer at all. I know this is possibly a basic Objective-C concept, but I just can't get my head around it. For example: int *pIntData = (int *)&incomingPa...

How to determine the result of a logical operator on nullable booleans?

In C#, for example, when I compare two nullable booleans (bool?) I get the following results : true & null = null false & null = false true | null = true false | null = null The issue is that I couldn't understand how those results come, what's the rule which I can use to determine the result of a logical operator on two booleans, whe...