# Search Results

• ### Confused with conditional and logical operators - VB.net

##### - by AgentRev
I'm kind of new to VB.net, and since I just finished a C# course, the lack of parentheses creates a lot of confusion on how to write certain combinations of operators. The C# equivalent of the line I am trying to reproduce in VB would be like this : if ( (a == 0 && b != null) || (a == 1 && c != null) ) I'm have no idea how to write this in VB, I've tried many combinations of And, Or, AndAlso, OrElse, etc. but I can't achieve the desired result. I can't find any clear example of C# v.s. VB.net comparison on operators, and the notes I have aren't helpful either. Can someone help me figure this out?

• ### One position right barrel shift using ALU Operators?

##### - by Tomek
I was wondering if there was an efficient way to perform a shift right on an 8 bit binary value using only ALU Operators (NOT, OR, AND, XOR, ADD, SUB) Example: input: 00110101 output: 10011010 I have been able to implement a shift left by just adding the 8 bit binary value with itself since a shift left is equivalent to multiplying by 2. However, I can't think of a way to do this for shift right. The only method I have come up with so far is to just perform 7 left barrel shifts. Is this the only way?

• ### Variable Operators in PHP

##### - by BenTheDesigner
Given this example, how would I return the result of the equation rather than the equation itself as a string? \$operator = '+'; foreach(\$resultSet as \$item){ \$result = \$item[\$this->orderField] . \$operator . 1; echo \$result; }

• ### How do boost operators work?

##### - by FredOverflow
boost::operators automatically defines operators like + based on manual implementations like += which is very useful. To generate those operators for T, one inherits from boost::operators<T> as shown by the boost example: class MyInt : boost::operators<MyInt> I am familiar with the CRTP pattern, but I fail to see how it works here. Specifically, I am not really inheriting any facilities since the operators aren't members. boost::operators seems to be completely empty, but I'm not very good at reading boost source code. Could anyone explain how this works in detail? Is this mechanism well-known and widely used?

• ### What is the point of the logical operators in C?

##### - by reubensammut
I was just wondering if there is an XOR logical operator in C (something like && for AND but for XOR). I know I can split an XOR into ANDs, NOTs and ORs but a simple XOR would be much better. Then it occurred to me that if I use the normal XOR bitwise operator between two conditions, it might just work. And for my tests it did. Consider: int i = 3; int j = 7; int k = 8; Just for the sake of this rather stupid example, if I need k to be either greater than i or greater than j but not both, XOR would be quite handy. if ((k > i) XOR (k > j)) printf("Valid"); else printf("Invalid"); or printf("%s",((k > i) XOR (k > j)) ? "Valid" : "Invalid"); I put the bitwise XOR ^ and it produced "Invalid". Putting the results of the two comparisons in two integers resulted in the 2 integers to contain a 1, hence the XOR produced a false. I've then tried it with the & and | bitwise operators and both gave the expected results. All this makes sense knowing that true conditions have a non zero value, whilst false conditions have zero values. I was wondering, is there a reason to use the logical && and || when the bitwise operators &, | and ^ work just the same? Thanks Reuben

• ### What are the primitive Forth operators?

##### - by Barry Brown
I'm interested in implementing a Forth system, just so I can get some experience building a simple VM and runtime. When starting in Forth, one typically learns about the stack and its operators (DROP, DUP, SWAP, etc.) first, so it's natural to think of these as being among the primitive operators. But they're not. Each of them can be broken down into operators that directly manipulate memory and the stack pointers. Later one learns about store (!) and fetch (@) which can be used to implement DUP, SWAP, and so forth (ha!). So what are the primitive operators? Which ones must be implemented directly in the runtime environment from which all others can be built? I'm not interested in high-performance; I want something that I (and others) can learn from. Operator optimization can come later. (Yes, I'm aware that I can start with a Turing machine and go from there. That's a bit extreme.) Edit: What I'm aiming for is akin to bootstrapping an operating system or a new compiler. What do I need do implement, at minimum, so that I can construct the rest of the system out of those primitive building blocks? I won't implement this on bare hardware; as an educational exercise, I'd write my own minimal VM.

• ### parsing string according to oracle operators with regex

##### - by haluk
Hi, Basically I was trying to replace the part of string with its actual value which comes immediately after oracle operators. I can do this for limited operators list like {=,,<} but I wonder that is there any way out to gather all the operators rather than giving them by hands? For instance, I have this string; "a = xyz", then I will replace xyz with lets say 3. But as you know we have bunch of operator namely "like,in,exists etc". So my string can also be this: "a like xyz". So what do you suggest me? Thanks.

• ### Why doesn't C have rotate left/right operators?

##### - by icepack
A bit of a philosophical question, I suppose. Hope it belongs here. C language has the standard set of bit-wise operations, including OR, AND, XOR, SHIFT LEFT/RIGHT, NOT. Anyone has an idea why rotate left/rotate right isn't included in the language? These operators are of the same complexity as other bit-wise operators and normally require a single assembly instruction, like the others. Besides, I can think of a lot of uses for rotate operator, probably not less than, say, xor operator - so it sounds a bit strange to me that they aren't included in C along with the rest. Edit: Please stop suggesting implementations of rotation operators. I know how to do that and it's not what the question about.

• ### Python operators returning ints

##### - by None
Is there any way to have Python operators line "==" and "" return ints instead of bools. I know that I could use the int function (int(1 == 1)) or add 0 ((1 == 1) + 0) but I was wondering if there was an easy way to do it. Like when you want division to return floats you could type from __future__ import division. Is there any way to do this with operators returning ints? Or could I make a class extending __future__._Feature that would do what I want?

• ### Understanding evaluation of expressions containing '++' and '->' operators in C.

##### - by Leif Ericson
Consider this example: struct { int num; } s, *ps; s.num = 0; ps = &s; ++ps->num; printf("%d", s.num); /* Prints 1 */ It prints 1. So I understand that it is because according to operators precedence, -> is higher than ++, so the value ps->num (which is 0) is firstly fetched and then the ++ operator operates on it, so it increments it to 1. struct { int num; } s, *ps; s.num = 0; ps = &s; ps++->num; printf("%d", s.num); /* Prints 0 */ In this example I get 0 and I don't understand why; the explanation of the first example should be the same for this example. But it seems that this expression is evaluated as follows: At first, the operator ++ operates, and it operates on ps, so it increments it to the next struct. Only then -> operates and it does nothing because it just fetches the num field of the next struct and does nothing with it. But it contradicts the precedence of operators, which says that -> have higher precedence than ++. Can someone explain this behavior? Edit: After reading two answers which refer to a C++ precedence tables which indicate that a prefix ++/-- operators have lower precedence than ->, I did some googling and came up with this link that states that this rule applies also to C itself. It fits exactly and fully explains this behavior, but I must add that the table in this link contradicts a table in my own copy of K&R ANSI C. So if you have suggestions as to which source is correct I would like to know. Thanks.

• ### What is Advanced Search Operators?

Search engines have set up further tools referred to as advanced search operators to provide power users possibly far more control when searching. Advanced search operators are distinctive phrases which you could insert in your search query for you to come across unique sorts of details of which the common search are not able to offer. A number of of those operators provide beneficial resources for Search engines gurus and other people who want really special data, or perhaps who wish to minimize their particular search to very specific source.

• ### Implementing Advanced Search Operators

Search engines have set up additional applications identified as advanced search operators to give sophisticated users additionally more management while searching. Advanced search operators are exceptional terms that you just can put in your search item for you to locate particular sorts of info that a standard search are unable to provide. Numerous of these operators supply handy tools for Search engines gurus and some others who require rather specific details, or maybe who prefer to minimize their search to really distinct results.

• ### Applying Advanced Search Operators

Search engines have developed additional applications termed advanced search operators to offer power internet marketers even more control each time searching. Advanced search operators are exclusive terms which you could place as part of your search query in order to come across unique sorts of details which a common search can not offer. A number of of those operators provide valuable tools for SEO specialists as well as other people who desire rather specific details, or maybe who need to restrict their particular search to extremely distinct source.

• ### Making Use of Advanced Search Operators

Search engines have set up extra tools referred to as advanced search operators to give professional users additionally more manage when searching. Advanced search operators are unique words that you simply can insert inside your search item in order to find unique sorts of details which a common search can not supply. Numerous of those operators produce handy tools for SEO professionals as well as other people who want really special details, or perhaps who prefer to control their search to very specific results.

• ### Faster C++ Operators

A method to eliminate redundant memory copying in C++ operators

• ### When to use Shift operators << >> in C# ?

##### - by Junior Mayhé
I was studying shift operators in C#, trying to find out when to use them in my code. I found an answer but for Java, you could: a) Make faster integer multiplication and division operations: *4839534 * 4* can be done like this: 4839534 << 2 or 543894 / 2 can be done like this: 543894 1 Shift operations much more faster than multiplication for most of processors. b) Reassembling byte streams to int values c) For accelerating operations with graphics since Red, Green and Blue colors coded by separate bytes. d) Packing small numbers into one single long... For b, c and d I can't imagine here a real sample. Does anyone know if we can accomplish all these items in C#? Is there more practical use for shift operators in C#?

• ### Real world use cases of bitwise operators

##### - by Olivier Lalonde
What are some real world use cases of the following bitwise operators? AND XOR NOT OR

• ### Equality and Assigment Operators

##### - by Jeremy Smith
I have a assembly compiled in VB.NET that contains two operators: Public Shared Operator =(quarterA As CalendarQuarter, quarterB As CalendarQuarter) As Boolean Return quarterA.StartDate = quarterB.StartDate AndAlso quarterA.EndDate = quarterB.EndDate AndAlso quarterA.Quarter = quarterB.Quarter End Operator Public Shared Operator <>(quarterA As CalendarQuarter, quarterB As CalendarQuarter) As Boolean Return Not (quarterA = quarterB) End Operator However, when using the assembly in C# to perform equality checks if (qtr != null) I receive the error: Cannot implicity convert type 'object' to 'bool' My original intent with the = operator was only for assignment purposes in VB, so I may be way off base (I don't use custom operators too often). What do I need to do to make the operator behave with both equality and assignment operations?

• ### SQL Operators as text in where clause

##### - by suggy1982
I have the following table, which is used for storing bandings. The table is maintained via a web frontend. CREATE TABLE [dbo].[Banding]( [BandingID] [int] IDENTITY(1,1) NOT NULL, [ValueLowerLimitOperator] [varchar](10) NULL, [ValueLowerLimit] [decimal](9, 2) NULL, [ValueUpperLimitOperator] [varchar](10) NULL, [ValueUpperLimit] [decimal](9, 2) NULL, [VolumeLowerLimitOperator] [varchar](10) NULL The operator fields store values such as < = <=. I want to get to a position where I can use the operators values stored in the table in a case statement in a where clause. Like this. SELECT * FROM table WHERE CASE ValueLowerLimitOperator WHEN '<' THEN VALUE < X WHEN '>' THEN VALUE > X END rather than having to write mutiple case or if statements for each permutation. Does anyone have any suggestions how I can decode the operators values stored in the table as part of my query and then use them in a case/where statement?

##### - by atch
Is it possible to define operators for enums? For example I have enum Month in my class and I would like to be able to write ++my_month. Thanks

• ### Other ternary operators besides ternary conditional (?:)

##### - by Malcolm
The "ternary operator" expression is now almost equivalent to the ternary conditional operator: condition ? trueExpression : falseExpression; However, "ternary operator" only means that it takes three arguments. I'm just curious, are there any languages with any other built-in ternary operators besides conditional operator and which ones?

• ### Dynamic Comparison Operators in PHP

##### - by BenTheDesigner
Hi All Is it possible, in any way, to pass comparison operators as variables to a function? I am looking at producing some convenience functions, for example (and I know this won't work): function isAnd(\$var, \$value, \$operator = '==') { if(isset(\$var) && \$var \$operator \$value) return true; } if(isAnd(1, 1, '===')) echo 'worked'; Thanks in advance.

• ### Esoteric C++ operators

##### - by Neil G
What is the purpose of the following esoteric C++ operators? Pointer to member ::* Bind pointer to member by pointer ->* Bind pointer to member by reference .* (reference)