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
1 answer

Shorthand arithmetic operators return different results in Scala - EG: 3 + 2 != 3.+(2)

Possible Duplicate: Scala operator oddity I'm very new to Scala and I read that in this language everything is an Object, cool. Also, if a method has only 1 argument, then we can omit the '.' and the parentesis '( )', that's ok. So, if we take…
Marsellus Wallace
  • 17,991
  • 25
  • 90
  • 154
0
votes
0 answers

Multiply or divide in C#/.NET

Possible Duplicate: Should I use multiplication or division? Poking around in some (C++) 3D library I often see code like this: float fInvLength = 1.0f / fLength; rkAxis.x = x * fInvLength; rkAxis.y = y * fInvLength; rkAxis.z = z *…
Sebastian Krysmanski
  • 8,114
  • 10
  • 49
  • 91
0
votes
1 answer

Arithmetic operators on lists/tuples in Python?

I have a couple functions like this: object obj.getChild(childIndex) int obj.numChildren() So I am using these to create this function: collection obj.getChildren() I am flexible in the return type, but I will doing a lot of "subtraction",…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
0
votes
3 answers

Check if the Nth number of Fibonacci is NthFib or not - arithmetic error fail

Here is my predicate, which should check if the Nth number of Fibonacci is NthFib or not. I am getting arithmetic is not function error. K - current iteration N - Nth number Tmp - previous Fibonacci number Ans - current Fibonacci number Fibonacci…
Jake Badlands
  • 1,016
  • 3
  • 23
  • 46
-1
votes
1 answer

What is the class of arithmetic operations in python?

I am currently making a simple calculator, and while I was trying to figure out what functions I should assign to tkinter buttons that represent arithmetic operations, this question hit me. So I tried to figure it out by using the type() but the…
user18427332
-1
votes
4 answers

convert temp from Celsius to Fahrenheit?

#!/bin/bash read -p "Enter degree celsius temperature: " C F=$(1.8*{$C})+32 echo The temperature in Fahrenheit is $F in above shell script i am trying to convert temp from Celsius to Fahrenheit getting this error /code/source.sh: line 3: 1.8{32}:…
-1
votes
1 answer

Print the array value which can produce the input by using addition operator

How do I edit the given program to get all possible combinations of array values which will provide the given data using addition operator? The following code works fine only if there is only one combination. For example, in the array =…
-1
votes
1 answer

Questions asks to work with pointers to return portion of string

int main (void) { char c[] = "KATEWINCE"; char *p =c; printf("%s", p+p[3]-p[1]) ; return (0); } The output is WINCE but I don't get how the code is working, please explain.
-1
votes
1 answer

Why does 11 / 1 % 2 / 11 give a different answer than (11 / 1) % (2 / 11) in Python?

I was just playing around with arithmetic operators in Python, when I encountered a strange thing of Python arithmetic. >>> (11 / 1) % (2 / 11) 0.0909090909090906 >>> 11 / 1 % 2 / 11 0.09090909090909091 Why is there a difference in both these…
coderboy
  • 1,710
  • 1
  • 6
  • 16
-1
votes
2 answers

Is a conditional statement required here?

I am building this program: A farm that sells eggs to customers charges $3.25 for a dozen eggs, or 45 cents for individual eggs that are not part of a dozen. Write a program that prompts a user for the number of eggs and then displays the amount…
-1
votes
1 answer

Is it possible to place a string inside df[ ] in python?

I know this is a bad one. I really want to know if this is possible to do in python so I have two strings with arithmetic equation now I want to place them inside a df[ ]. df is a data frame Is this possible to do? X = "'cars'+'bikes'*'planes'" Now…
krish
  • 61
  • 9
-1
votes
4 answers

Why does dividing a int with a float result in a float?

Question why does this happen? Is this just a C language thing? I'm following the cs50 course. #include int main(void) { int testInt = 5; printf("%f", testInt / 4.0); } Output is 1.250000 -- float value
sw30
  • 77
  • 5
-1
votes
2 answers

console shows 6 when i multiply integer (3) into string ("2") in JavaScript

Hey could you please tell me why this happens when I add var a = 3 var b = "2" console.log(a + b ) // 32 the above output is right But when I do subtraction then it shows console.log(a - b ) // 1 and it is the same for multiplication (o/p:- 6) and…
PRADEEP GORULE
  • 159
  • 1
  • 11
-1
votes
1 answer

Evaluation of arithmetic expressions with a cellular automaton

Stephen Wolfram talked about this thing called cellular automaton. The idea was building what are seemingly complex systems from simple rules and starting configurations. Some examples such as Milton Bradley's game of life are demonstrated in this…
-1
votes
1 answer

It is not working as expected. How can i fix this code?

I want the code to increase my semi_annual_income every six months, by making the the semi_annual income increase every six months with by specific percentage. so it was suppose to be according to my math 1000(1.2)^i/6 this equation would increase…
J jezani
  • 1
  • 1