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
1 answer

Why do I have to add a decimal to get this math correct in C++

I was calculating the volume of a sphere and after tons of research I found that I cannot use: float sphereRadius = 2.33; float volSphere = 0; volSphere = (4/3) * (M_PI) * std::pow(sphereRadius, 3); But must add the 3.0 instead to get the right…
Michael Rader
  • 5,839
  • 8
  • 33
  • 43
0
votes
1 answer

Why is this skipping numbers when I divide it?

Here is the code: #include #include #include #define BUFFER 512 void getCount(int *numCount, int *count); int sumNumbers(int *numSum, int *sumNumOutput); int main(void) { printf("Enter a number greater than 0:…
DFT95
  • 27
  • 5
0
votes
2 answers

The math calculations behind using (%, //) in python by applying (Decimal(), signed numbers )?

I was trying to understand the math behind calculations using / and // and % operators by doing some trials and found the results are similar to calculator only when using Decimal() but without it the results kinda confusing, i tried to add comments…
WAlbaker
  • 13
  • 1
  • 6
0
votes
2 answers

Division by using 2 cut variables

I have the following code : #!/bin/bash pontos=$(cat condutores.txt | cut -d ":" -f 10) nviagens=$(cat condutores.txt | cut -d ":" -f 9) divisao=$((pontos / nviagens)) echo $divisao I want to divide the 10th column of each line with 9th column of…
0
votes
1 answer

Python - How to divide numbers in list of lists?

Hi i have been trying to get the mean of each sub-list using sum/length. vectors = [[2.731018, 1.7550012, 2.3455532], [2.9210236, 3.2172325], [2.9255183, 2.66712, 2.7174947]] mean_vec = [sum(i)/len(i) for i in vectors] Currently i am using the…
Cua
  • 129
  • 9
0
votes
1 answer

Why am I getting `ZeroDivisionError: float division by zero` error?

I want to find a function's x value at y=0. from pynverse import inversefunc from math import pi,sqrt R=20 C=5*10**-9 L=5*10**-4 Z= (lambda x: sqrt(R**2+(1/(2*pi*C*x)-2*pi*L*x)**2)) inversefunc(Z,y_values=0) But I get following error…
0
votes
1 answer

how to determine data type of arithmetic expressions involving divisions in c++

Have a look at the following programme. // Example program #include #include int main() { int n=7; std::cout <<"n/2 = "<< n/2 << std::endl; std::cout <<"n/3.3 = "<< n/3.3 << std::endl; } output : n/2 = 3 n/3.3 =…
0
votes
1 answer

Div/0 in Calculated Field VBA Pivot Table

I am trying to remove my 'Div/0' error on my outputted Excel Sheet using my VBA Code. My calculated field "AFC_pct" is causing the Div/0 error. I am unable to use the =IfError function because I keep getting a compile error .CalculatedFields.Add…
Jenna Terral
  • 67
  • 2
  • 11
0
votes
2 answers

Divide integer by 12 and show if remainder is odd or even

Trying to create a program that asks the user to input a number between 20 and 100. After the number has been entered. The program will divide the entered number by 12. The program will then say if the result of the division is even or odd.…
0
votes
1 answer

hdparm -tT /dev/sda Grab result into variable

Ok I am trying to find a way I can run hdparm -t /dev/sda 10 time and grab the output and get an average result. This does not give me what I am looking for: Can't figure out how to grab just the MB/sec counter=1 total='' average='' while […
Albert Mulder
  • 147
  • 1
  • 12
0
votes
7 answers

How to check divisibility of a number in continuous fragments by 11 in c++

Given a number num find out how many continuous fragments of the given number is divisible by 11 for example given 1215598 these continuous fragments could be…
0
votes
1 answer

DAX : optimize measure in SSAS 2012 tabular model

-I use SSAS 2012 SP4 tabular version. The cube contains 2 facts tables and each one uses the same dimension tables (=7 dimension tables). There is no relation defined between 2 fact tables. -The following measure is setup in Fact2 table: Measure1…
ema
  • 17
  • 3
0
votes
2 answers

Enable scroll for Readonly DIV over another div

I have a DIV with some content which needs to be in Read-only mode, so i have overlapped it with another DIV and set cursor:no-drop. This works well and make my content read-only, But it also doesn't let the user scroll over the content DIV. How can…
Crazy Dev
  • 11
  • 2
0
votes
3 answers

Division of two values from array always return 0

I have this function that is suppouse to return a number that should be or 1 or 2 or 4, but when the division happens, the variable duracion always get the value 0 as result. I have tried a lot of changes but no one was the solution. // Converts a…
ManKino
  • 47
  • 4
0
votes
0 answers

Gamma function in python doesn't plot what I expected

I'd like to plot a Levy distribution characterized by the following PDF's: Below there's my code: import matplotlib.pyplot as plt from scipy.special import gamma import numpy as np def Levy(x, n, a): num1 = gamma((n+1)/2) den1 =…
XaBla
  • 43
  • 2
  • 13
1 2 3
99
100