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
2
votes
2 answers

arithmetic vector operations in Java

I have four vectors have same dimension (1 dimensional) and same size. My vectors are consturcated as: Vector v1=new Vector(5); Vector v2=new Vector(5); Vector vp=new Vector(5); Vector
JoshuaJeanThree
  • 1,382
  • 2
  • 22
  • 41
2
votes
2 answers

Char is an arithmetic type?

I created a Matrix class, using static_assert(std::is_arithmetic::value,""); to check if the template type is an arithmetic type. So I tried with Matrix matrix1(3,3); // ctor takes number of rows and columns and it works. The…
user1434698
2
votes
1 answer

how to do arithmatic operations in linux using awk or sed and piping the result to a file

with this problem I am beating my head with walls, please help. I have two files Sheetthickness.k which contains a single value of initial thickness and minThick.k which contains the final thickness only a single number. I want to calculate the…
hamad khan
  • 369
  • 1
  • 5
  • 14
2
votes
1 answer

Computing 64-bit values in 32-bit mode

I'm writing a C99 compiler that works with 64-bit values. For starters, this will compile 32 bit and 64 bit code. On 64 bit operating systems, I know I can use the r[]x registers. But for the 32 bit code, how do I do it. I've tried loading the value…
Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
2
votes
1 answer

Incrementing an integer in xslt

There is a question with a similar title, but an entirely different question body: How to increment a XSL integer variable I get a parameter $level passed to a template and want to apply templates on $level + 1, while $level is guaranteed to always…
bitmask
  • 32,434
  • 14
  • 99
  • 159
1
vote
1 answer

How to do arithmetic expression evaluation in prolog?

I am trying to solve an arithmetic expression in prolog (implementation - eclipse prolog). The arithmetic expression to be solved is like this: A * (C + B * X) + D * X = E X is the value to be computed, and all others (A,B,C,D,E) are all numbers.…
kallakafar
  • 725
  • 3
  • 11
  • 27
1
vote
1 answer

arithmetic expression evaluates to zero when with parenthesis

I have the above code private float farenaitCelsiusMath(float f) { float result; result = (f-1)*(2/3); return result; } when i run the app on the emulator it evaluates to 0 whatever value i give to f. But when the third…
tioschi
  • 389
  • 1
  • 3
  • 11
1
vote
2 answers

Why awk arithmetic doesn't work?

I have simple script: #!/bin/sh #NOTE - this script does not work! #column=${1:-1} column=1+1 awk '{print $'$column'}' But when run ls -la | ~/test/Column.sh I receive always 1 1 1 1 What the problem?
user710818
  • 23,228
  • 58
  • 149
  • 207
1
vote
2 answers

Execute an arithmetic expression in Android

I want to do an arithmetic operation on data stored in an Array. User may choose random column and random operation on them. like, String DataTmp[10][3] = ...; String strCalc = "Float.parseFloat(DataTmp[i][0]) + Float.parseFloat(DataTmp[i][2]) *…
BobbyGoks
  • 11
  • 2
1
vote
0 answers

Compare two integers with bitwise operation

I saw a bunch of codes which can do simple arithmetic operations in constant-time. But there is a code makes me curious. Here is a code written in C. int ct_lt_u32(uint32_t x, uint32_t y){ return (x^((x^y)|((x-y)^y)))>>31; } This function…
1
vote
4 answers

How can I reliably perform an arithmetic shift right in C++?

The "arithmetic shift right" operation is similar to a normal (logical) shift right, except the most significant (i.e. shifted-in) bits are filled with the sign bit rather than 0. Unfortunately, in C++ (prior to C++20, and also in C), the result of…
1
vote
2 answers

How does Java handle the intermediate values while evaluating a long arithmetic expression?

I was wondering how does Java handle the intermediate values while evaluating a mathematical expression specially when the intermediate values exceeds their storage size. For an example, int a = 1103515245; int x = 1013904223; int c = 2531011; x =…
abhimanyue
  • 196
  • 1
  • 12
1
vote
0 answers

How is it valid syntax in Java to use an assignment operator in a larger arithmetic expression?

Context: I'm mainly a Javascript/Python developer and I'm doing Java just for schoolwork. This is the code block that perplexes me. public static void display(int a, int b) { a = a+b-(b=a); System.out.println(a); System.out.println(b); } I…
1
vote
1 answer

arithmetic operations on a columns of a data set, using the index of a row as a variable in pandas

So i'm not using python on my day to day basis so this is kind of new to me, but I have large amount of csv files to edit and I imagine a simple script can save me a lot of time. suppose I have a table input data I want to create a new table that…
1
vote
1 answer

How to overcome fixedpoint division problem in chisel3?

When I am running a code for testing in fixedpoint, I am getting an error. Can anyone help me with the code??? Code: import chisel3._ import chisel3.util._ import chisel3.experimental.FixedPoint import…