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
0
votes
1 answer
How best to represent nested logical expressions in JSON
I am in need of an interface to build rules in a web application. There is a need to maintain state and I would like to know what would be the most appropriate method to store a nested logical expression (Example (a>b && a>c) || (a==0))
Is JSON…

SamD
- 120
- 1
- 10
0
votes
1 answer
char to int conversion error in c
I am giving a 1000 digit number as input, and using this program to find max product of 5 consecutive integers. The array a is used to hold the sequence with highest product.I am getting an unexpected answer(I suspect the problem to be in conversion…

Nitin Labhishetty
- 1,290
- 2
- 21
- 41
0
votes
2 answers
how to read arithmetic data from text file and handle operations in perl
I have a text(example.txt) file which has numbers and arithmetic operations e.g.
10+5*6
8+(4*3)
...
I want to handle these operations and generate output like below in another text file (output.txt)
10 + 5 * 6 = 40
8 + (4 * 3) = 20
...
I'm new to…

Raghav2580
- 256
- 2
- 10
0
votes
3 answers
Concatenating longs and floats into a long
I have two numbers:
1234567890 <--- Long
and
0.123456 <--- Float
Is there any way to combine these to make a float(or double) in the following format:
(123)4567890.123456
I don't mind if the numbers in brackets have to be removed.

Alex
- 3,031
- 6
- 34
- 56
0
votes
0 answers
Approximate specified integer with random arithmetic operations
The example will work faster: I have some numbers (ie: 2, 3 and 7) and must combine them with any operations (+, -, * and /), so I approximate as much as possible to a given number.
So, for a target number 21, it would find that 3 x 7 is the best…

julifos
- 142
- 1
- 2
- 10
0
votes
1 answer
parser for arithmetic expressions
I am trying to implement a simple parser for solving arithmetic expressions,such as
"(9+7)*(10-4)".Right now I am just testing my codes with some simple calculations like "9+7" etc. It allows the user to input an string but after i enter the…

user2939823
- 1
- 3
0
votes
2 answers
How can I display a composed arithmetic expression? like (3.3+6.2)*1.2 instead of 9.5 * 1.2
my super class(abstract):
exp1.display will display my result
exp1.evaluate should return ((1.2 * 4.2) + 4.2)) but it returns only (5.04 + 4.2)
I need
help with my evaluate method and
a test class but to test and see if the operations from my…

user2946804
- 27
- 1
- 4
0
votes
1 answer
Using of arithmetic and logical operators in switch statement
I want to use logical operators in switch statment.
For Example:
" x is greater than 3 and is less than 7 "
Using it in If statement.
if(x > 3 && x < 7)
{
//something
}else if(x 11 3 && x < 15){
// anything
}
How can I use it…

Axeem
- 670
- 4
- 16
- 26
0
votes
1 answer
Prolog solving prefix arithmetic expression with unknown variable
I want to make an arithmetic solver in Prolog that can have +,-,*,^ operations on numbers >= 2. It should also be possible to have a variable x in there. The input should be a prefix expression in a list.
I have made a program that parses an…

knordbo
- 552
- 3
- 7
0
votes
1 answer
problems with basic arithmetic in a function (Matlab)
I have defined a really basic function in matlab. It takes no input and returns an array of 10 floating point numbers.
The problem I have is that when I run the function to return the array I want I get incorrect values, however when I substitute…

JMzance
- 1,704
- 4
- 30
- 49
0
votes
5 answers
Can somebody explain how javascript Arithmetic expressions work?
Let's evaluate this code for swapping two variables :
var a = 5, b = 3;
a = ( a -( b = ( a = a+b ) - b ) );
I was expecting that new value of a should be 3 and value of b should be 5. But I got values as a = 0 and b = 5;
I went and read the…

Shidhin Cr
- 868
- 8
- 19
0
votes
1 answer
(Java) How to use extended precision arithmetic to handle bigger factorials?
The Program reads in a command-line argument N, and prints N! = 1 * 2 * ... * N to standard output.
public class Factorial {
// return n!
// precondition: n >= 0 and n <= 20
public static long factorial(long n) {
if (n < 0)…

user2470562
- 19
- 1
- 6
0
votes
2 answers
Matlab syms variable precision?
Just having some issues with variable precision in matlab..
I have the code:
x = 0.1;
syms y;
S = solve(x+1==(1+y)/(1-y),y);
y = double(S);
val = abs(((2^2)*(y^2))/(2*(y-1)^2))
But val is always rounded off.
I should be getting val = 0.0049999 but…

Travv92
- 791
- 4
- 14
- 27
0
votes
2 answers
Arithmetic expression grammar in prefix notation (Java Cup)
I'm writting a grammar for arithmetic expression in prefix notation. However I have an issue when parsing negative numbers or substraction. Grammar example is this:
precedence right +, -;
precedence right *, /;
precedence right uminus;
E ::= + E E
…

Julián Chamalé
- 607
- 11
- 23
0
votes
3 answers
Perform summation of integers on each line in a file in `cmd`
Time for some command line fu in the least fu conducive shell, cmd.exe.
How can I perform a summation of integers contained in a file?
You might consider the following to work:
taskkill /f /im rsync.exe
echo %errorlevel% >…

brandeded
- 2,080
- 6
- 25
- 52