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

Get divisible numbers in a range without certain operators (+, -, /, *, %, += %=, etc)

find numbers in an input range that are evenly divisible by 3. Only =, ++, -- operators can be used. I've tried to get the remainder using shift operators and other loops but I always require a -= or something similar. Console.Clear(); …
BPierce
  • 53
  • 5
0
votes
2 answers

LibCrypt what is the use of the `ctx` parameter on BN_div?

In my attempt to implement the Burmester-Desmedt key agreement using pure C I need to divide 2 public keys thus I thought the BN_div should do the job. int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a, const BIGNUM *d,BN_CTX *ctx); But when I…
Dimitrios Desyllas
  • 9,082
  • 15
  • 74
  • 164
0
votes
1 answer

Python Decimal module giving different numbers than calculator

I want to get large amount of accurate digits in results from divisions, such as 1/7, but Python gives different results than a high-precision calculator. I tried the decimal library with Python 3 and tried changing its precision and rounding mode,…
0
votes
1 answer

How can I handle a division by zero within this case statement

Within this case statement I have a "divide by". How can I modify this to handle div by zero errors? CASE WHEN INVOICE_V.INVC_TYPE = 0 then (((INVC_ITEM_V.PRICE - INVC_ITEM_V.TAX_AMT)*INVC_ITEM_V.QTY) - (INVC_ITEM_V.COST *…
0
votes
0 answers

convert integer to fixed point in division operation

I have this code in my project. library ieee; use ieee.std_logic_1164.all; use ieee.numeric_std.all; library ieee_proposed; use ieee_proposed.fixed_pkg.all; entity sfixed_test is port(x1 : in integer :=20; x2 : in integer := 23; …
0
votes
3 answers

Dividing a row by reference value in mysql

Please help me. Here is the raw data: uid | id | value | 1 | a | 389 | 2 | b | 201 | 3 | c | 170 | if.... When the reference value is '200' How do you get it to come out like this? mysql.. no| uid | id | value | cut 1 | 1 | a | …
0
votes
0 answers

Problem when decimals are greater than 5 .net

What i have is a time series as below 2018/01/01, 100 2018/01/02, 50 2018/01/03, 0.05 I divide each value by 1000 the result looks like this 2018/01/01, 0.1 2018/01/02, 0.05 2018/01/03, 5E-05 now the problem with the 3rd data point is it's…
UndeadEmo
  • 433
  • 1
  • 6
  • 15
0
votes
0 answers

Python Matrix division

I have a problem concerning dividing matrices element wise, whereby I mean that I want element [i,j] of the first matrix(foto_dcp, see code) to get divided by element[i,j] of the second matrix(Q) . Some background information : I loaded in an image…
Marius.db
  • 15
  • 1
  • 6
0
votes
2 answers

Call a private method in public method in a class

I want to overload operator/ in a class. to do it I want to define private inversion method which calculate inversion of first complex number(1/Z1) and then multiply by the second complex number. I developed the code which give me an error Exc20.cc:…
user7656997
0
votes
1 answer

Dividing one column in a dataframe by a number while bringing back all other columns in the dataframe

I am trying to divide one column in a dataframe by a number while bringing back all other columns in a dataframe unchanged. The code below works for the division, but I dont know how to bring back the columns I wanted unchanged from the dataframe as…
burnsa9
  • 131
  • 2
  • 3
  • 10
0
votes
0 answers

Division Objective function in Pyscipopt

I am trying to maximize the division of two quantities in PySCIPOpt. Since it is a division of two linear metrics, it becomes a nonlinear optimization. My code is somewhat like this: model = Model() x={} for i in range(0,len(data)): x[i] =…
0
votes
1 answer

Dividing two integers, giving the integer quotient and remainder without dividing or multiplying in R

inspired by these posts: stackoverflow post 1, stackoverflow post 2, geeksforgeeks post I wanted to write an algorithm in R to divide two integers, giving the integer quotient and remainder without dividing or multiplying. However, I am struggling…
Sarah
  • 137
  • 9
0
votes
2 answers

C integer and float division output

Can somebody explain the output of the following code: http://cpp.sh/9dy44 Why is the last line always 0.17? float a = 17, b = 100; printf("%f\n", 17/100); printf("%f\n", a/b); printf("%f\n", 17/b); printf("%f\n", 17.0f/b); printf("%f\n",…
hicksi
  • 43
  • 3
0
votes
0 answers

division algorithm in maple

I try to write the function which is determine remainder of long division algorithm Specifically, find the remainder of polynomial f on the divison by F with F is the family of polynomials. I got stuck and here is my code. with(Groebner); LT :=…
Soulostar
  • 101
  • 2
0
votes
0 answers

R not calculating remainder correctly

I have a list of numerator and denominator that I want to see if the numerator is divisible by the denominator (i.e. remainder being zero), please see the dataset in R as below: structure(list(numerator = c(40.77, 38.88, 117.6, …
lokheart
  • 23,743
  • 39
  • 98
  • 169