Questions tagged [division]

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

In mathematics, especially in elementary arithmetic, division (÷) is an arithmetic operation. Specifically, if b times c equals a (b × c = a) where b is not zero, then a divided by b equals c (a ÷ b = c).

In the expression a ÷ b = c, a is called the dividend, b the divisor and c the quotient.

In programming, division is usually represented by the / symbol. There are two import forms of division in most programming languages:

  • In floating point division which operates on floating point or other rational numeric datatypes, the fractional part of the result is included (to the accuracy provided by the datatype):

    float a = 5.0;
    float b = 2.0;
    float c = a / b;   // c = 2.5
    
  • In integer division which operates on integral numeric datatypes, the fractional part of the result is discarded, as in following example:

    int a = 5;
    int b = 2;
    int c = a / b;     //  c = 2
    
2262 questions
0
votes
0 answers

My polynomial GCD implementation in Maple giving wrong result

I am new to Maple and trying to implement the gcd of 2 polynomials using euclide's algorithm. I was quite sure of my code, but i am getting weird fractional results with(Algebraic); euclide:=proc(a, b) local r0, r1, tmp, q; r0 := a; r1 := b; …
0
votes
0 answers

Divide each element in a matrix by one element in R

Consider the following matrix: matrix <- matrix(1:9, nrow = 3, ncol = 3) [,1] [,2] [,3] [1,] 1 4 7 [2,] 2 5 8 [3,] 3 6 9 For the two first columns ([,1] and [,2]), I want to divide each element until row [3,] with…
Michael
  • 565
  • 4
  • 11
0
votes
2 answers

"Trace/breakpoint trap (core dumped)" error when dividing by negative value in Assembly

I have written out a small assembly program that divides two numbers, then displays the results through C printf function. The program asks for user input for the numbers, then does division as so: mov rax, r14 ;r14 holds the numerator cqo mov rbx,…
lawgik
  • 87
  • 3
  • 10
0
votes
3 answers

Why am I getting the wrong division answer?

Super simple - I'm running a useEffect function in React. I need to do a simple calculation, but I keep getting the wrong answer. Example, I get 10 as an answer instead of the expected 8,960... I thought it might be a string and not an Int at first,…
Ronald Langeveld
  • 694
  • 1
  • 8
  • 23
0
votes
0 answers

Why does 2//0.2 return 9.0 but 5//0.5 return 10.0 in Python

In Python 3 interpreter, 1//0.1 2//0.2 4//0.4 returns 9.0, but 5//0.5 3//0.3 returns 10.0. Is this rounding-off behavior correct?
Anuvrat Tiku
  • 1,616
  • 2
  • 17
  • 25
0
votes
3 answers

How to efficiently calculate number of possible combinations (when selecting at least one of each type)?

This is the exercise I am trying to solve: Problem statement Jack, the pirate finally found the treasure.He found that there were infinite numbers of coins but he can collect only N coins and the coins belong to R different countries (coins will …
Andy
  • 40
  • 6
0
votes
1 answer

Python division returning incorrect result

I want to write a function that takes in 2 values and calculates whether the division is an integer, but i am having trouble handling the case when say 5.1 and 0.1 is entered as the result is not 51 as expected. def(a,b): return…
0
votes
0 answers

What is the difference between these bits of code

I am just experimenting with some things in python, and one of my problems required a funny solution of changing a / to a //. What's the difference? def is_multiple(number=None, m=None): # m representing times table if not number or not m: …
xupaii
  • 465
  • 4
  • 15
  • 31
0
votes
2 answers

Why aren't all the area elements used in the calculations?

I'm trying to do some simple calculations to get calculated leakage using this formula: calculatedLeakage=((averageCurrent/(averageVoltage/1000.0))/area[z]) but I noticed that only the last element of list area is being used in my formula and I…
user2241397
  • 69
  • 2
  • 11
0
votes
1 answer

python division with large numbers automatically ceiled

Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> print(111111111111111111/10) 1.1111111111111112e+16 >>>…
thunderbird
  • 2,715
  • 5
  • 27
  • 51
0
votes
1 answer

how to make a new column if a condition is fulfilled?

I want to make a warning column to warn the user of database if a condition is fulfilled. I currently have data like this. item stock_need rto doi PRE 24DX4SX15G 200 4800 14 PLS 12RX10SX15G 240 2400 …
0
votes
1 answer

Error: "Invalid operands to binary /"

I'm using this code for the moving, scaling and rotating an UIImageView. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { CGPoint currentTouch1; CGPoint currentTouch2; NSArray *allTouches = [touches allObjects]; …
Tim
  • 13
  • 1
  • 9
0
votes
2 answers

Removing space created inside my container

I have a container that has an image and on top of that image a button, but inside the container some "extra" space was created, at the right. I need to remove this extra space because its taking too much space. 3 horizontal images are aligned at…
Eduardo
  • 264
  • 2
  • 10
0
votes
1 answer

Why can't I divide a BigInt with another BigInt and save it to a variable I've initialized with zero?

I have the following code snippet: use num_bigint::*; // 0.2.2 use num_traits::*; // 0.2.8 use std::ops::*; fn xgcd(b: &BigInt, a: &BigInt) -> (BigInt, BigInt, BigInt) { let mut x0: BigInt = One::one(); let mut x1: BigInt = Zero::zero(); …
0
votes
1 answer

dividing two columns grouped by region in R

I'm trying to divide two columns via month by amount grouped by their region. My dataset looks like this: month Amount Region 10 2 APAC 20 5 EMEA 10 3 APAC 10 4 NA 4 3 NA I have tried the…