Most voted "operators" questions
Operators are symbols that occur in almost every programming language and coding, for performing calculations and comparisons on data. Use the tag only when operators are relevant to the problem, including questions about syntax, in any language.
Learn more…330 questions
Sort by count of
-
4
votes3
answers122
viewsModule Operator invokes special object methods
To biblioteca padrão do Python has the module operator, studying the same I noticed that some of its functions have say "aliases", for example: operator.setitem(a, b, c) operator.__setitem__(a, b,…
-
4
votes1
answer97
viewsWhat does the ">" operator do in the middle of an arithmetic expression in C++?
I found this line of code in a proposed solution to a certain problem. excedente = a % 10 + b % 10 + excedente > 9; My point is, what function is that the > 9 makes this line me specific?…
-
4
votes3
answers81
viewsDifference in arithmetic and assignment operators practice
package entities; public class Product { public String name; public double price; public int quantity; public double totalValueInStock() { return price * quantity; } public void addProducts(int…
-
4
votes1
answer278
viewsInterpretation of logic operators in Java regarding short-circuit
I read that question Doubt about logical operators && e || in Java, but I follow with the doubt. Solving some exercises on Java I find such a statement: Operators & and | operate in the…
-
4
votes1
answer516
viewsWhat does & Python mean? What is your name? is an operator?
I was looking over the loop while in Python, and everything was going well, but suddenly I see: "&", that even searching I could not find anything about. i = 0 while i < 5 : print(i) i =…
-
4
votes2
answers609
viewsDifference between ?. and ?? in C#
I looked at the documentation of Microsoft but still I found it a bit confusing, the main things I managed to abstract were: "?." - is a conditional null operator and tests the value of the left…
-
4
votes2
answers211
viewsWhy is it wrong when I try to assign a value to the variable within a conditional operator?
I have the following code that should receive 4 numbers and tell which one is the largest. #include <stdio.h> int max_of_four(int x, int z, int y, int w); int main() { int a, b, c, d;…
-
4
votes2
answers318
views"-" operator cannot be applied to a string
I’m trying to make some changes to a ready code, but I came across a problem with a line of code written in C#: string[] textArray1 = new string[] { -899253461.ToString() }; In this case, Visual…
-
4
votes2
answers88
viewsWhen compiling the code, both numero1 and numero2 display the same value even having an increment
public class IncrementoDecremento{ public static void main(String[] args) { Integer numero1 = 10; Integer numero2 = ++numero1; System.out.println("numero: " + numero1 + ", numero2: " + numero2); } }…
-
4
votes1
answer58
viewsWhat is the difference between the function call with ":" and "."?
In ruby it is possible to make a call from some method, either from some object, either using :: how much using .. What is the difference between them?
-
4
votes2
answers96
viewsHow does logic test work with two integers in Python?
I was analyzing a code and came across the following expression: 1 & n >> k Where n and k are integers. For now, I’m focused on the first part of the expression. I’ve never seen a logic…
-
4
votes1
answer47
viewsWhy does the "delete" operator not remove references to a deleted Javascript property?
I am reading a book about data structure in Javascript and came across the following situation: why delete does not delete a reference value? I will give an example to be clear. const items = { a:…
javascript characteristic-language objects operators deleteasked 3 years, 7 months ago Mr Genesis 464 -
4
votes1
answer123
viewsWhat is the difference between the rest operator (%) in Python and Rust?
Writing a small program in Rust, I noticed that the operator results % are different from what I get in Python for negative numbers. For example, in Python -4 % 26 returns 22, but in Rust: fn main()…
-
3
votes3
answers205
viewsProblems with logic (&& or ||)
I found strange the code that is in my system: if (cmbCdTipoProcesso.SelectedValue != "3" && cmbCdTipoProcesso.SelectedValue != "4") {....} Apparently the code is weird, 'cause I’ll never…
-
3
votes1
answer236
viewsHow to create a modular function whose parameter is an operator?
Suppose I want to create a function that changes the src of an image by another in the index of an array, thus: var arrayimgs = ["js/img1.jpg","js/img2.jpg","js/img3.jpg"]; var imagem =…
-
3
votes2
answers452
viewsCan I use a char in an arithmetic operation in Java?
The following code doesn’t work, but I thought something along those lines: char op = '*'; ... r = (y op x); I want to change the characters of op to do different operations, it would be possible in…
-
3
votes1
answer104
viewsUnexpected Behavior, XOR Logical Operator - PHP
why it is possible to see this behaviour of the logical operator xor? $bool = false xor true; var_dump($bool); // bool(false) $bool = true xor false; var_dump($bool); // bool(true) from what I read,…
-
3
votes1
answer180
viewsIs it true that ++$variable (preincrement) is faster than $variable++ (post-increment)?
It is true that ++$variavel is faster than $variavel++? In that reply given in SOEN, we see the following excerpt: ... However pre-incrementing is Almost 10% Faster, which Means that you should…
-
3
votes1
answer128
viewsWhy can’t I modify the string this way?
When we have a declared int variable, and then a pointer to that variable: int x = 10; int *p = &x; To modify the variable x through the pointer, we have to do: *p = 20; But when I declare: char…
-
3
votes4
answers3830
viewsCompare number within a numerical range
I want to create a function that receives a number and check if it is within a range from 1 to 25. What is the best way to do this? private int VerificaIntervalo(int numero) { if (numero > 25) {…
-
3
votes2
answers75
viewsWhat do increment operators do in arrays?
Accidentally I was creating a PHP script and unintentionally put an increment operator in a variable whose type is array. To my surprise, no error was shown by PHP. I did some tests and found that…
-
3
votes2
answers65
viewsIncremental result?
I have a doubt about this expression: y-=++x I can divide this expression in two? x= x+1 and then?
-
3
votes1
answer120
viewsWhy is an expression with rest and multiplication giving the wrong result?
Why is this code giving as a result -2 and not 7? #include <stdio.h> main() { printf("%i\n", 105 % 3*4 - 3*4 % (101 / 10)); system("pause"); }
-
3
votes3
answers135
viewsDifference of null and another proposition using this null object
If I have a code, for example: if(window!=null && window.isOpen()){ //todo } If window for null, Will he still try to call the second proposition or not check anymore? Because if he tries to…
java operators nullpointerexception null conditionasked 8 years, 3 months ago Mateus Carvalho 1,494 -
3
votes4
answers17399
viewsAverage between 3 notes
I need the user to enter 3 notes to calculate the average, and tell if he is approved, failed, or recovery. I believe the error is in the average itself. <html> <head> <title>…
-
3
votes1
answer1250
viewsWhat does the "|=" operator mean? (with pipeline and no exclamation)
I was doing some research and came across the operator in sequence |=. Look at: mBuilder.getNotification().flags |= Notification.FLAG_AUTO_CANCEL; There is this operator in JAVA, but I do not know…
-
3
votes1
answer1722
viewsWhat is the real difference between the operator '=' and LIKE?
Doing another test (rs) in a database I have in Mysql, I realized that: SELECT * From client WHERE uuid = '1kvsg4oracxq' returned the same result as: SELECT * From client WHERE uuid LIKE…
-
3
votes2
answers715
viewsWhat does && ! mean in PHP?
I am trying to know this, but it appears nowhere. There is a gap between & & e !. if ( is_home() && ! is_front_page() )
-
3
votes1
answer100
views -
3
votes1
answer171
viewsHow to do mathematical operations with a struct?
I have the following structure: public struct vetor { public float X, Y; public vetor(float X, float Y) { this.X = X; this.Y = Y; } } And this code: Vars.vetor _visao; Vars.vetor _recoil; //Os 2…
-
3
votes1
answer323
viewsWhat does the function of %% and %any% on the r?
I’ve been reading the R’s documentation and the document Arithmetic{base}, Arithmetic Operators I came across the %% who claims to have the mod function, which I assumed was the modulo function, but…
-
3
votes2
answers169
viewsWhen to use Stringbuilder and Stringbuffer instead of concatenating with "+" operator in Java?
What are the benefits of concatenating a string using StringBuilder or StringBuffer instead of simply using the operator +?
-
3
votes1
answer508
viewsPHP ternary operator gives unexpected result
Recently I did a test and there was a question asking what the return of expression: $var = true ? '1' : false ? '2' : '3' I replied that the result would be '1', but the correct result is '2'. If…
-
3
votes1
answer61
viewsWhy do I need to add a parenthesis under multiple conditions of a ternary operator?
Let’s start from the following values: $foo = 1; $bar = 1; As the extra condition placed on else without parentheses, the result does not match the intention of the operator: echo ($foo &&…
-
3
votes1
answer90
viewsWhat are considered operators in the programming language?
I was wondering if a token is considered an operator when performing an action?
characteristic-language operators syntax language-independent tokenasked 5 years, 1 month ago Hyago M. Vale 33 -
3
votes1
answer88
views -
3
votes2
answers349
viewsHow to calculate the result of an arithmetic expression contained in a tuple respecting the operators' precedence?
I have a tuple containing the tokens of an arithmetic expression: ('5', '+', '2', '*', '5'). I tried to calculate the result of the expression, but it is not respecting the precedence of the…
-
3
votes2
answers71
viewsAllocation of values other than normal
def testes(x, y): while y: x, y = y, x % y return x I don’t understand this part of the code, what happens with the 'x' and the 'y' on the left side of the equals sign and what the 'y' does on the…
-
3
votes0
answers35
viewsHow does the Python identity operator work?
I’m starting in Python and would like to ask a question based on the code below: Case 1 x = 5 y = 5 print(x is y) # retorna True Case 2 x = "carro" y = "carro" print(x is y) # retorna True Case 3: x…
-
3
votes2
answers239
viewsWhat is the difference between ", " and "+" in Python?
In a code mensagem = "ola " nome = input("Diga seu nome ") print (mensagem + nome ) mensagem = "ola" nome = input("Diga seu nome ") print (mensagem , nome ) The two do the same function , with the…
-
2
votes2
answers353
viewsHow to increment variables
In the code below my variable y asks the user to enter values until y reaches 10, I store the variable x and currently the last information typed is stored (which shows at the end of the code) what…
-
2
votes1
answer65
viewsDifference between "Object(meuobjeto)" and "(meuobjeto as Object)"?
I wish I knew the difference between using Object(meuobjeto) and (meuobjeto as Object) based on the code below: var mc:MovieClip = new MovieClip(); //Um objeto MovieClip trace(mc as String); //null…
-
2
votes2
answers588
viewsDoubt about the MOD operator in PHP
I have a code PHP that performs a certain calculation, however it is resulting something different than I expect, I performed the calculations in hand and did not generate the same result, anyone…
-
2
votes2
answers1206
viewsWhat does the "?:" operator mean in PHP?
What the operator means ?: in PHP? Example: $a = 0; $b = false; $c = 3; echo $a ?: $b ?: $c; Upshot: 3 What exactly is he doing in the expression above? Is that a ternary? If not, what do you call…
-
2
votes2
answers6996
viewsProgram that sums/multiplies 2 numbers and what’s between them and prints
I believe the logic of this programme is right, but the result is wrong. Make a program that receives two X and Y numbers, being X < Y. Calculate and show: the sum of the even numbers in that…
-
2
votes2
answers81
viewsHow to use the LESS "when" operator?
I quickly searched the site of Less to see how it is used, but I was not successful, so I wanted to know how the operator works when less!? Examples: box-shadow(@style, @c) when (iscolor(@c)) {…
-
2
votes1
answer102
views -
2
votes1
answer1420
viewsdo the multiplication of values using sum operator and while
var n1 = Number(window.prompt(" digite o primeiro número ")); var n2 = Number(window.prompt(" digite o segundo número ")); var soma; var num = 0; while( num…
-
2
votes2
answers909
viewsHow to use Operator= to copy a pointer vector?
Having this class, I would like to implement, operator =, copy the pointer vector to int for another vector, it is obligatory to reserve memory before doing so? What’s the difference between making…
-
2
votes2
answers72
viewsComposite allocation operator
I can’t understand why he won’t perform the expression I want. Follows the code: $i = 1; $ranking = 1; $r = 0; for($i = 1; $i <=5; $i++){ $p = isset($_GET["n$i"])?$_GET["n$i"]:0; echo "$ranking °…