An arithmetic expression is an expression that results in a numeric value. There are two kinds of numeric values, integers (whole numbers), and real or floating point numbers (numbers containing a decimal point).
Questions tagged [arithmetic-expressions]
677 questions
-1
votes
2 answers
How this sum is being calculated
I'm doing java and I'm having trouble understanding how it's calculating this sum. 5+3/2*7-8=4
How it's getting 4?
The order in which arithmetic operators are applied in
a calculation are as follows:
1. Negation, -
2. Multiplication and Division, *,…

TomHanks
- 1
- 8
-1
votes
1 answer
Need an explanation about evaluating a given expression
The expression is as follows
(ux-uy) == -(unsigned) (y-x)
where x and y are random integers and ux and uy are declared and defined as follows
unsigned ux = (unsigned) x;
unsigned uy = (unsigned) y;
I tested the expression in c with various numbers…

user1335175
- 181
- 7
- 20
-1
votes
1 answer
gmp for R and other sols
implemented a solution to a problem in arithmetic precision handeling in gmp - but the results are rather strange . as a part of troubleshooting I was wondering whether there is any other package hich woudl allow similar operatiosn as gmp in R. I…

heineman
- 25
- 6
-1
votes
2 answers
Interesting output using variables with NSLog() in objective-c
The following code:
int N = 100;
double total_time = 100;
double dt = total_time/N;
NSLog(@"Answer: %d", dt);
gives an interesting output: 5766 instead of 1.
Only in the case of adding
NSLog(@"Answer: %f", dt);
outputs the right answer. However,…

Darius Miliauskas
- 3,391
- 4
- 35
- 53
-1
votes
5 answers
Why is 3-1*8+2*3 equal to 1
I used PEMDAS on 3 - 1 * 8 + 2 * 3.
Steps:
1) 1 * 8 = 8
2) 2 * 3 = 6
3) 8 + 6 = 14
4) 3 - 14 = -11
Multiply all the terms, then add and finally subtract but I get -11 as the result.
But when I googled it, it said 1. Where did I go wrong?

Nicholas
- 679
- 2
- 11
- 29
-1
votes
1 answer
Returning no. of orders and average spending for each customer in a given month using mysql
I have tables on my database with schema:
customers (customerID: integer, fName: string, lName: string)
items (itemID: integer, description: string, price: integer)
orders (orderID: integer, itemID: integer, aID: integer, customerID: integer, date:…

mar
- 111
- 2
- 4
- 10
-1
votes
3 answers
for in loop arithmetic
operation = ['/','*','+','-']
a =5
b= 2
for op in operation:
output = a+op+b
print output
Here the output I get is
5/2
5*2
5+2
5-2
but I want
2.5
10
7
3
What is the way to do it?

Rahul Sonwalkar
- 3
- 2
-1
votes
1 answer
How do I make a program with complex numbers?
The lack of knowledge of complex numbers doesn't allow me to make the program. C++.
Task: Given real numbers u1, u2, v1, v2, w1, w2. Get 2u + (3uw)/(2+w-v) - 7, where u,v,w - complex numbers: u1+iu2, v1+iv2, w1+iw2. (Determine procedures for…

user3501137
- 23
- 1
-1
votes
1 answer
How many bits do i need to store AB+C?
I was wondering about this-
If A, B are 16-bit numbers and C is 8-bit, how many bits would I need to store the result ? 32 or 33 ?
And, what if C was a 16-bit number? What then ?
I would appreciate if I got answers with an explanation of the hows…

Floose
- 525
- 2
- 7
- 15
-1
votes
5 answers
Which is wrong? Java, Maths or Me...?? Confused...!
I've the below SOP:
System.out.println(9 - ((9 / 2) * 2));
From the maths that I learnt in school, it should evaluate to 0.
But I'm getting the output as 1...!!!
I've tried evaluating the same expression in Google the output is 0.
Java evaluates to…

Gokul Nath KP
- 15,485
- 24
- 88
- 126
-1
votes
1 answer
Order of operation for subtraction?
This may be an uneducated question - or an odd one of the kind.
My question is why this code doesn't work:
if (up == true)
{
SDL_Delay(pause_t);
player.setY(player.velocity - player.getY());
}
…

user1707244
- 23
- 5
-2
votes
0 answers
Output Statements and Expressions
print(, , ..., , end="\n")
SyntaxError: invalid syntax
print("The answer is", end=" ")
print(3 + 4)
SyntaxError: multiple statements found while compiling a single statement
Expected output:
The answer is 7
print("The answer…

Annmarie
- 1
- 1
-2
votes
1 answer
Multiplication always results in 0 despite using the float data type
#include
int main()
{
float income;
printf("enter your annual income here:");
scanf("%f", &income);
if (income < 250000)
{
printf("no income tax"); /* code */
}
else if (income >= 250000 && income <…

Ayush kumar Rai
- 1
- 2
-2
votes
1 answer
How can I use different computational operations to get the results of two numbers in C++?
I am trying to get the results of two different numbers using "+","-", and mod"%" operators. However, I am running into trouble in coding it. I am using a textfile of numbers that look like this: 57854879876656543423468 and 654589876578097433579, to…

beginnercoderuh
- 11
- 6
-2
votes
1 answer
Regular expression to see if string is a whole number or a fraction
need to check if a string is whole number between 1 and 99. so allow maximum 2 characters here.
OR
a fraction with a slash must be compulsorily 3 characters with slash at the 2nd character
and the numerator[1-8] always smaller than the…

Sachin Nayak
- 1
- 2