Top "Division" questions

In mathematics, division (÷) is an arithmetic elementary operation.

In Python, what is a good way to round towards zero in integer division?

1/2 gives 0 as it should. However, -1/2 gives -1 , but I want it to round towards 0 (i.e. I want -1/2 …

python rounding division negative-number integer-division
ArithmeticException thrown during BigDecimal.divide

I thought java.math.BigDecimal is supposed to be The Answer™ to the need of performing infinite precision arithmetic with …

java precision division bigdecimal financial
Integer division in awk

I want to divide two numbers in awk, using integer division, i.e truncating the result. For example k = 3 / 2 print …

awk integer division
java integer rounding (division related)

I have run into a surprise with integer division not rounding down as expected. Simple code: public class HelloMath { public …

java integer rounding division truncation
Division in VB.NET

What's the difference between / and \ for division in VB.NET? My code gives very different answers depending on which I …

vb.net division
Division result is always zero

I got this C code. #include <stdio.h> int main(void) { int n, d, i; double t=0, k; …

c double division multiplication integer-division
Division in Java always results in zero (0)?

The function below gets two values from sharedpreferences, weight and height, and I use these to calculate the BMI, When …

java android division
Division by zero error

I have this code throwing up the error: <?php $val1 = $totalsum; $res = ( $val1 / $val2) * 100; $val2 = count($allcontent); $res = ( $val1 / $…

php division divide-by-zero
Numpy array element-wise division (1/x)

My question is very simple, suppose that I have an array like array = np.array([1, 2, 3, 4]) and I'd like to get …

python numpy division
Negative integer division surprising result

In my application I encountered the following and was surprised by the results: 8/-7=-2 (both integers). what does this …

python division integer-division