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

C# - How To Convert/Display a Floating-Point/Exponential Result into a Full/Whole Number

I am using C# inside .Net Environment. I have some really large integer values entered by user which are than divided by each other and the result is displayed. Now we know that 4/2 = 2 is simple but what if we…
Muhammad Ali
  • 72
  • 10
0
votes
2 answers

Division algorithm for calculating quotient without keeping track of remainder

As a spare-time project, I'm trying to implement some cryptographic algorithms using free-standing C - that is, the variant of C without standard library functions (standard library types and constants are still available), and without optional…
DannyNiu
  • 1,313
  • 8
  • 27
0
votes
2 answers

What is the time complexity of this division function (no divide or multiply operators used)?

I solved this leetcode question https://leetcode.com/problems/divide-two-integers/ . The goal is to get the quotient of the division of dividend by divisor without using a multiplication or division operator. Here is my solution: def…
0
votes
1 answer

Programming Percentages in PL/SQL

--56/25000*100 = 0.244 = 0.2 % as percentage column answer I am trying to write out this math problem as a query in pl/sql. The table looks like this Test_Name , Total# Pass, Fail, Percent, View_name I need to write out a query that divides the…
0
votes
1 answer

What's the case of float division returning inf and finite value?

I have written this snippet of code and I cannot understand why this float division returns inf when args[2] = 200 and 5.0 when args[2] = 2000. Is this caused because I am exceeding some decimal position boundary? #include #include…
Giannis
  • 75
  • 9
0
votes
4 answers

Dividing two integers and rounding up result to nearest integer

I have two int numbers a, b always >= 0. I want to divide a by b and return the rounded up percentage to the nearest integer. Example: 18/38 should return 47 and 13/38 should return 34. How can I accomplish this? I tried the following but it didn't…
BigMon
  • 51
  • 11
0
votes
0 answers

Divide Vector by matrix

I want to translate a Matlab code and I'm kind of stuck. I want to calculate A/B where A is a 1x3 vector and B a 3x3 matrix. In Matlab it works perfectly. The solution should be C. I thought about changing the formula to AB^(-1) What have I…
Martin
  • 312
  • 2
  • 15
0
votes
2 answers

Efficient check of float division by zero for embedded application

For the embedded SW application on a microcontroller I have to write a some kind of customised division operator for float. The solution, I want to go with, is shortly described below. In fact, I am not sure if this approach could be efficient…
0
votes
0 answers

Division of Python Complex Numbers

I am trying to divide two complex numbers and not getting the desired result. How does division work for Python Complex numbers ? Input values are: (2+3j) and (2+3j) I have tried the below logic and this does not seem to work. numerator_real = (real…
0
votes
1 answer

Problem with MIPS division

I need help with debugging the following code. I've tried like 10 times or more but I still don't understand why I got such a weird output as seen below: Enter a: 5 Enter b: 2 a/b = 268501012 (<--- weird output) # task4partial.asm # Given…
Jan
  • 1
0
votes
2 answers

How to do correct division for large numbers in Python?

Why is there an error for division in both: int and float? and how to correct it? print(int(231871064940156750/5),231871064940156750/5%100) # output: 46374212988031352 52.0 # correct number: 46374212988031350
J Sha
  • 15
  • 5
0
votes
2 answers

Transparent box that cuts through box behind it

Is there some way I can get the box not show the pink? That is have all the area within the box show the blue of the body? Ideally the solution not being something where I make four pink divs around the box but using the divs I already have. Maybe…
Harper Creek
  • 437
  • 6
  • 19
0
votes
4 answers

SQL divide 2 columns

I need to calculate population density in SQL. I have a column with population and a column with area but I'm can't figure out how to execute it, I get a division by zero error. Here is what I tried: select name, population, gdp, area,…
Trisha
  • 13
  • 1
  • 6
0
votes
2 answers

Division by NULL in IBM DB2

In Oracle, any number divided by NULL returns NULL. I was wondering what is the case for DB2 Databases? The whole point of it is to check whether the following expression behaves in the same way for Oracle and DB2: SELECT a / NULLIF(b, 0) FROM…
0
votes
3 answers

substitute a value according to specific condition in R

i have a df structured like this: Value. Numb. 46. 200 47. 200 55. 200 21. 200 32. 140 23. 140 56. 700 If numb value is repeated, I want to substitute the value with the result of the division Numb/number of…
Silvia
  • 405
  • 4
  • 17