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

R getting very small number instead of zero

In the code below, snapshot should be 0 if TrimCY = TrimBYS. df <- df %>% mutate(snapshot = case_when(Trend_direction != 2 ~ (TrimCY-TrimBYS)*sign(Trend_direction)*10/abs(Target_Snap-TrimBYS), TRUE ~…
kristenj
  • 31
  • 3
1
vote
1 answer

Math question on solving modular equations

I have the following modular equation: 327≡ ℎ*327*327* ≡ ℎ*327 ≡ 1 (mod 1009) and so ≡ ℎ*327x ≡ ℎ*1 ≡ ℎ (mod 1009). So I have to find out what ℎ is. 3*327=981≡-28(mod1009) What i don't understand is how the 3 is derived here, by what formula…
oppressionslayer
  • 6,942
  • 2
  • 7
  • 24
1
vote
1 answer

VB .Net Different Arithmetic Result in Two Apps

i have a compiled Vb .Net Program that have below Arithmetic line when i want to use this line in new App has different result the code is : Protected Sub MethodOne(ByRef A_1 As UInteger,A_2 As UInteger,A_3 As UInteger,A_4 As UInteger,A_5 As…
Conry
  • 11
  • 2
1
vote
1 answer

Updation of the variable

def fun(x): x += 1 return x x = 2 x = fun(x + 1) print(x) It is said that the variable , declared outside the function , cannot be written but read in a function, unless the variable is declared global , so how can here the value of x is…
1
vote
1 answer

How to create a custom data type that supports arithmetic operations as any other generic data type

I am trying to create a new type UInt24. In order to do so, I am using a struct (any better suggestion would be welcome). While I am now able to cast a variable to this new defined type, I am unable to support generic arithmetic. I have tried a…
stackMeUp
  • 522
  • 4
  • 16
1
vote
3 answers

Adding together any number of items in an array with Javascript

I am learning Javascript and currently having an issue creating an application. I want to create a webpage that will take the values entered in a textbox, and place them inside an array. Then, I want to create a function that will add the values…
1
vote
2 answers

while executing asking for two input values

#include int main() { int minutes=0; double days=0.0; double years=0.0; printf("enter minutes "); scanf("%d ",&minutes); days= (minutes/60)/24; years=days/365; printf("no of minutes %d equals no of days are %f ,…
user63555
  • 17
  • 3
1
vote
1 answer

How to evaluate String as expression to perform arithmetic operations on String in Rust, so that when user type 3 + 1 on console it gives 4

I was trying to make a calculator in the Rust programming language. The calculator performs basic arithmetic operations like add, sutract, exponent etc. The challenging part for me is that the user input is a String and I want the calculator to be…
Taimoor
  • 67
  • 8
1
vote
2 answers

SAS - PROC SQL - Case When arithmetic not making sense

In SAS Proc SQL, I am using this Case statement to try to mark policies that have differences other than .015 per year: CASE WHEN (MOD1 - MOD0) NOT = .015 THEN 2 WHEN (MOD2 - MOD1) NOT = .015 THEN 3 WHEN (MOD3 - MOD2) NOT = .015 THEN 4 …
Yugy
  • 11
  • 1
1
vote
1 answer

printf() is printing the wrong value

This is my full code, and its printing random negative values each time I run it not sure what is wrong. using Ubuntu to run and "gcc -Wall -Wextra test.c" #include int main () { unsigned int x = 10; unsigned int y = 16; unsigned int p =…
Thomas
  • 43
  • 6
1
vote
1 answer

how does java define the result of an arithmetic expression

I am writing a parser for Java however, I am a little lost when it comes to operations on primitive types. For example i have these expressions: int i; long l; float f; short s; byte b; //this is being cast from a float to an int? should this be a…
jordan t
  • 136
  • 10
1
vote
4 answers

How to perform element-wise arithmetic operations (e.g. add, subtract, multiply) of two equally shaped lists with arbitrary nestings

I want to perform element-wise mathematical operations (e.g. sum, multiply..) on two Python lists containing numbers or multiple nested lists which may contain again numbers or lists and so on. The shapes of the two lists are equal when performing…
1
vote
0 answers

JavaScript Numerics: multiply first then divide?

I just found an arithmetic bug that, very simplified, when multiplying two numbers and then dividing, the order of operations give different values! In this case, multiplying first gives the correct answer: (1455/1279) *…
backspaces
  • 3,802
  • 6
  • 34
  • 58
1
vote
1 answer

How to build a comparison operator (comparitor) in an arithmetic circuit

I am trying to convert a basic program into an arithmetic circuit. I am stuck on the step of converting the greater than operator into an arithmetic circuit. To be specific, I do not know how to convert the following into an arithmetic circuit…
1
vote
1 answer

Dividing two columns in R

I have a .txt data file and I want to perform a very simple operation, namely creating a vector/column with values that are created by dividing a column of the .txt by another column of the .txt. It seems very trivial but I haven't found out how to…
Mathbeginner
  • 201
  • 1
  • 8