Questions tagged [arithmetic-expressions]

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).

677 questions
0
votes
2 answers

python random arithmetic game

I'd like to create a program that generates two random numbers and applies a random arithmetic function to them and then prints the answer. So far I've made the numbers and the calculations but I do not know how to print the sum out or generate an…
0
votes
1 answer

What's wrong with the smarty arithmetic I did?

Following is the smarty arithmetic code I tried but it's not working: {if $cur_page == 1} {assign var='i' value=1} {else} {assign var='i' value=$cur_page * 15 + 1} {/if} Can someone please correct my code? If you want any other information…
PHPLover
  • 1
  • 51
  • 158
  • 311
0
votes
2 answers

Do different arithmetic operations have different processing times?

Are the basic arithmetic operations same with respect to processor usage. For e.g if I do an addition vs division in a loop, will the calculation time for addition be less than that for division? I am not sure if this question belongs here or…
WYSIWYG
  • 494
  • 6
  • 23
0
votes
0 answers

Double arithmetic giving false result

I don't know why this code below is giving me "no". I tried to cast -0.2 to double and still getting "no"? What is the problem and how to fix it? double d = -4; double d1= -4.2; if (d1== (d-0.2)) cout<< "yes"<
Mariya
  • 847
  • 1
  • 9
  • 25
0
votes
3 answers

Confusion with post increment and logical operator?

#include #include main() { int i=-1, j=-1, k=0, l=2,m; m = i++&&j++&&k++||l++; printf("%d%d%d%d%d", i, j, k, l, m); } Output: 00131 I am confused how the expression is getting…
nitesh.kodle123
  • 1,041
  • 4
  • 11
  • 23
0
votes
1 answer

DB2 EXP() command returning arithmetic overflow

Hi I am using the EXP() command in DB2 on a column of type float as so select distinct 1 - power(0.9144,exp(beta - 0.1)) from mytable where this all works fine until I introduce the exp() around (beta - 0.1). beta is a float and ranges between…
brucezepplin
  • 9,202
  • 26
  • 76
  • 129
0
votes
0 answers

Android weird "divide by zero" exception in ListView

I am using GA to tracking my applications. I have noticed that there is a weird exception reported sometimes on every release. The reported calling stack shows that it seems to be the Android issue of the user's device(I can never reproduce this…
Robin
  • 10,052
  • 6
  • 31
  • 52
0
votes
0 answers

Prolog simple addition

I am teaching myself Prolog (using SWI on linux), and I am trying to learn basic arithmetic. Take a look at the example program below. When I attempt to ask any of the following thee questions Prolog tells me the procedure total1/2 is…
Andrew S
  • 2,847
  • 3
  • 33
  • 50
0
votes
0 answers

Java Binary Tree expression stack

I'm trying to parse an arithmetic expression for a Binary Tree using stacks. So far I have: package home2; import chapter7.binaryTree.*; import chapter7.tree.NonEmptyTreeException; import chapter5.nodeStack.*; public class Expression { private…
Snowyace
  • 1
  • 1
  • 1
0
votes
3 answers

Problems with Java Generics and Addition arithmetic

Does anybody know why Im getting this error? error: cannot find symbol return left.evaluate() + right.evaluate(); symbol: method evaluate() location: variable left of type T where T is a type-variable: T extends Object…
Subiendo
  • 47
  • 7
0
votes
1 answer

CPU Usage from Linux then using it in a arithmetic expression

I have this line in bash, cpu=`top -bn1 | grep "Cpu(s)" | sed "s/.*, *\([0-9.]*\)%* id.*/\1/" | awk '{print $1}' Thats working as I want it if I echo it but when used in the next line as part of a equation. joulesFinal=$(($joules2*$cpu)) I get the…
0
votes
1 answer

USing Variables/JAVA functions in SQL arithmetic statements in JAVA Netbeans

I am trying to query my database by using a Java function with another attribute defined in the database. The statement generates no error. However, the output is wrong. The result of the output is null but from my checking it is not null. Please…
user3048253
  • 1
  • 1
  • 4
0
votes
1 answer

VB.NET Simple Arithmetic operation

I have a simple arithmetic to perform in VB.Net, which is as follows; I've got m_Variable5 of type String = "325" which is passed from another object. The operations are; m_Variable5 = Convert.ToString(Convert.ToInt32(m_Variable4, InvariantCulture)…
Nadeem_MK
  • 7,533
  • 7
  • 50
  • 61
0
votes
4 answers

Arithmetic operation with a void?

I know that the following, if possible, would be an absolutely bad practice, but I want to know if this is possible. The question is the following: is it possible in C++ (and in a way the compiler does not throw any warning), to perform a useless…
Vincent
  • 57,703
  • 61
  • 205
  • 388
0
votes
1 answer

Bash grep from text file and edit

I am doing a update on the file test.txt which stores some info about storybooks I've the code below for the function but i realise that using this method of grep, i am unable to get the rest of the values for price quantity and sold which are not…