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
vote
1 answer
Element-Wise Arithmetic Operations in Jagged Multidimensional Arrays in JavaScript
I want to perform some element-wise arithmetric or mathematical operations on 2D jagged-arrays without flattening the output array; in this example, array C.
const A = [[1, 2, 30, 4],[5, 16, 7],[8, 9, 12, 14, 90]];
const B = [[45, 60, 15,…

Isaac
- 396
- 3
- 13
1
vote
2 answers
Arithmetic operations in prolog
How is it possible to obtain 28 using 7 10 3 2 in this order and without using parentheses?I've been thinking for the past 1 1/2 hours and I couldn't get anywhere.

sutrivmz
- 11
- 1
1
vote
1 answer
How can I get the parse tree for arithmetic operations in Python?
How do I obtain a list of function calls for this following simple arithmetic operations? How can I get the parse tree?
Python 2.7.15rc1 (default, Nov 12 2018, 14:31:15)
[GCC 7.3.0] on linux2
Type "help", "copyright", "credits" or "license" for…

john mangual
- 7,718
- 13
- 56
- 95
1
vote
2 answers
Converting conditions to arithmetic expressions
As a part of particle system simulating gravitation and collisions between many objects I came across a strange bug.
This is a school project aimed at optimization through vectorization (OpenMP SIMD) and as a part of the optimizations I wanted to…

doomista
- 501
- 2
- 10
1
vote
1 answer
How to compare percent file size in an if
Im trying to do this in a bash shell. Basically want to compare the size of two files by there percentage. If file1 is 90% different then file2 do something:
This is what I have so far:
newsize=$(wc -c <"$newfile")
oldsize=$(wc -c <"$oldfile")
if…

Tags
- 172
- 3
- 16
1
vote
2 answers
Trying to convert this formula into an arithmetic expression in Java
I'm trying to take user input in the form of myMonthlyPayment, myAnnualInterestRate, and myPrincipal in order to calculate the number of months needed to pay off debt by using The formula I've attached to this post. What I have in eclipse for the…

Logan
- 21
- 3
1
vote
2 answers
Arithmetic operation (Difference) between a vector and a Matrix in R
I am facing this issue when I am trying to calculate the difference between list and matrix in R, it is giving me weird results.
matrix <- matrix(1:10,1:10,nrow = 10,ncol=10)
list1 <- seq(1:10)
diff <- list1-matrix
Below is the output that I am…

kawsleo
- 560
- 4
- 23
1
vote
1 answer
my arithmetic expression doesnt work in a CMD FOR loop
I want to generate a random number in a For Loop like that (part of it):
FOR /F "delims=, eol=; tokens=1,2" %%a in (DATA.TXT) DO (
SET min=10000
SET max=99999
SET /a passwort=!min!+(!max!-!min!+1)*%random%/32768
)
Unfortunately, it…
user10060833
1
vote
2 answers
Is any float number | 0 = a fixed number?
Suppose I wrote the codes like this following:
console.log((5/3)|0)
The result is 1.
However why? In my mind, |0 means +0. But why can it cancel off the fractional part?
Can anyone give me a full understanding of that by showing its inner binary…

xqMogvKW
- 628
- 7
- 17
1
vote
2 answers
How to convert the string '100+20*50/10-9' to float value using python
Haii friends
How can I convert the string expression value to float value
ex: s1 = '100+20*50/10-9' this s1 convert to float value. Based on the arithmetic operator priority rule it should give 191. But the string expression is not convert to…

Maddela Tejaswini4029
- 41
- 1
- 8
1
vote
2 answers
Why are my numbers not calculating correctly in my Number Guessing game?
Why are my numbers not calculating correctly? My teacher wouldn't give me more help because he thought it was close enough to his output. But I'm not satisfied. First of all here is my finished code:
#include
using namespace std;
void…

andreaq
- 17
- 5
1
vote
1 answer
VHDL -1 rem 4 returns 3, why?
Take the following VHDL code:
to_signed(-1, 32) rem to_signed(4, 32)
From what I understand from various sources and this SO question this should produce the result -1, but it returns 3, just as mod. Why?
Thank you!

Piedone
- 2,693
- 2
- 24
- 43
1
vote
0 answers
C# usual arithmetic conversions - result/operand types of arithmetic operations?
In C# arithmetic operations on number types can result in a value with a different type than either of the operands. Take the following snippet for example:
byte x = 10;
byte y = 20;
var z = x + y;
Here z will be int.
My questions would be:
What…

Piedone
- 2,693
- 2
- 24
- 43
1
vote
2 answers
Is there any way to give a format to arithmetic computations in Objective-C?
i want to define something similar to a computation method:
NSString *format = @"%d + 1";
In my code i want to do something like:
int computedNumber = sum(format,5) => the result should be 6.
could you give some suggestions?
thank you
EDIT:
or…

Sorin Antohi
- 6,145
- 9
- 45
- 71
1
vote
0 answers
Order of operations edge case in Mac osx calculator?
I'm currently learning how to code in swift. So, I gave myself the challenge to code a calculator similar to the basic mac osx calculator.
My issue is that when I click:
4 + 2 * 3 * = I get 30 - paper tape (4 * 2 * 3 + 6 = 30)
4 * 2 + 3 * = I get…

user3768804
- 139
- 1
- 1
- 15