Questions tagged [division]
In mathematics, division (÷) is an arithmetic elementary operation.
2,167
questions
-1
votes
0
answers
49
views
Assert failing but it receives the right values?
I'm coding a function in my BSTree that calculates the average numbers of children by dividing the counted children by the total nodes. I get the desired answer from my assert, but it still crashes ...
0
votes
0
answers
18
views
Where should we use intdiv() function vs PHP 8 division operator `/` with (int) casting?
intdiv($a, $b) vs (int)($a / $b)
Do we still need or should use the intdiv() function to calculate integer quotient of the division of num1 by num2, knowing that since PHP8 division operator / is also ...
3
votes
2
answers
28
views
SwiftUI String formatting is rounding my values to nearest whole number?
I hope you're all well!
I have a (potentially) silly question. I'm attempting to learn SwiftUI development by recreating the Instagram UI.
Right now, I'm working on the user page that shows a single ...
-1
votes
0
answers
41
views
Why does the division operator behave differently in Java when used in an expression that also uses a multiplication operator? [duplicate]
In the following Java code, while computing the value of y, i / j evaluates differently. In the first calculation, the division operator results in floor division and gives 1, while in the second ...
0
votes
1
answer
38
views
ZeroDivisionError: float division by zero tried to resolve but failed
import math
avg_cost = []
for [e,l] in lis:
length = ZomatoData[(ZomatoData["establishment"]==e) & (ZomatoData["locality"]==l)].shape[0]
avg_cost.append(math.ceil(...
0
votes
2
answers
26
views
Dividing each column in a pandas df by a value from another df
I have a dataframe of a size (44,44) and another one (44,)
I need to divide each item in a column 'EOFx' by a number in a column 'PCx'.
(e.g. All values in 'EOF1' by 'PC1')
I've been trying string ...
0
votes
1
answer
37
views
÷ division sign in flutter dart
what is the name of division ÷ sign in icons section in flutter dart?
I tried this code but the sign is not ÷
FloatingActionButton(
onPressed: _divideCounter,
tooltip: 'divide',
backgroundColor: ...
-2
votes
0
answers
23
views
How can I Add Popunder Ads js script only under A division Which Has Video on my website
<script type='text/javascript' src='pop under Link here'></script>
This is an ad script i want to use popunder ad only If A person click on Embedded video on my website of which code look ...
2
votes
1
answer
46
views
Golang BigInt division
I have a problem with function and i don't understand why it happen. The problem is: i have a big number, but when i'm trying to make some operations of division - I have zeros.
The code is:
for {
...
0
votes
2
answers
63
views
How to divide one row by another with same value in a specific column?
I have a dataframe following this pattern:
Measure
Key
mai/21
jun/21
jul/21
...
mar/22
apr/22
Units
4040
100
102
104
...
200
204
Total Value
4040
10500
10700
11000
...
22000
22200
Units
3230
120
...
-1
votes
1
answer
29
views
Calculation over pandas groupby object with condition within groups
I have a df as follows:
appid month tag totalvalue
0 1234 02-'22 B 50.00
1 1234 02-'22 BA 10.00
2 1234 01-'22 B 100.00
3 2345 03-'22 BA 25.00
4 2345 03-'...
2
votes
1
answer
24
views
Trying to find the inverse of the matrix in C, but the program is not calculating correctly
There was a question that I needed to find the inverse of the matrix (actually it's about cryptography, but never mind) and to be honest the code works. Nevertheless, if you insert certain numbers ...
0
votes
3
answers
53
views
How to separate the Full number and Decimal Number from a Divison Result in Python
For python
After division, if the result has any decimal number with the full number, I just want to get the full number and ignore the decimal number.
for example:
130/33 = 3.939393
here I just want ...
0
votes
0
answers
28
views
JavaScript Division on floating returns strange result [duplicate]
I am building a Metrics Converter site where precise calculations matter a lot and I noticed a strange issue when performing these metrics calculations.
Let me post a few instances which I have come ...
0
votes
1
answer
30
views
Divide individual grouped items in pandas
Following df:
appid tag totalvalue
0 1234 B 50.00
1 1234 BA 10.00
2 2345 B 100.00
3 2345 BA 25.00
4 2345 BCS 15.00
What we want is to group the df with appid and ...
-1
votes
3
answers
37
views
Trying to input a fraction and split it into a list but it causes problem when the numbers are more than 1 digit
fraction = list(input("Enter: "))
print(fraction)
When Inputting "99/100" I wanted it to print ["99", "/", "100"] not ['9', '9', '/', '1', '0', '0']
2
votes
1
answer
40
views
pandas perform division between 2 tables (1 aggregated) with different size
I am a newbie to pandas and I am struggling to get the result that I want after doing research / experiencing some trial and errors...appreciate any guidance from here, thanks in advance!
Supposed I ...
-1
votes
1
answer
66
views
Speed of numpy array division
I'm processing a lot of 16bit image data and have been trying to figure out more efficient ways to handle it. What I'm doing is loading images and then dividing by a reference "calibration" ...
-1
votes
2
answers
44
views
if the number is divisible by 3 print A and if it divisible by 5 print B and if it is divisible by both print C without using more than 2 if statement
if the number is divisible by 3 print A and if it is divisible by 5 print B and if it is divisible by both print C without using more than 2 if the statement (dart will be preferred)
2
votes
3
answers
65
views
How to keep decimal accuracy when dividing with floating points
I am working on a project, and I need to divide a very large 64 bit long value. I absolutely do not care about the whole number result, and only care about the decimal value. The problem is that when ...
0
votes
2
answers
33
views
How to use for loops when dividing multiple values from lists in Python? [duplicate]
I am trying to divide values from two lists by each other, and I want to output a list with the quotients. The problem I am having is that all of the values are going through each other and dividing.
...
0
votes
3
answers
49
views
How to split each line of a text file into three parts with python
I have a text file that contains a string for each line
ABDASLDJIJD
HSKNKSLUDHNJJNŞKSJ
SNKJBAKHSLIJSKM
...
I just want to split each line into three parts and store each part in a different text file (...
0
votes
1
answer
33
views
I created a division program in visual studio, c# , but cant seem to make it answer with decimal numbers [duplicate]
this is the code of my program:
`Console.WriteLine("This is a division app");
Console.Write("Please input a whole number(maximum is 2,147,483,647): ");
int ...
-2
votes
3
answers
78
views
Difference between // and round() in Python
Is there a difference between using // (Integer Division) and the built-in round() function in Python? If I understand correctly, both will round to the nearest Integer but I'm unsure if the behaviour ...
0
votes
1
answer
41
views
How to divide in Panda Python
I generated the following code:
cov_vac_merge['Partially Vaccinated'] = cov_vac_merge['First Dose'] - cov_vac_merge['Second Dose']
cov_vac_merge['% Partially Vaccinated'] = cov_vac_merge['Second Dose'...
2
votes
3
answers
77
views
DIV fade in onscroll with JQuery but without triggering on each pixel
I have an SVG inside a DIV that is supposed to start at 0% opacity and then fade in to 100% via jQuery when I scroll down to 800px. Currently, it's:
Loading at full opacity (instead of 0%) before ...
0
votes
2
answers
53
views
How to calculate a division with lag? x[-1] / x[-length(x)]
how can I calculate a division with lag 12?
Monthly data example:
2000-01: 179.300
2000-02: 179.400
2000-03: 180.000
2000-04: 180.300
2000-05: 180.700
2000-06: 181.100
2000-07: 181.500
2000-08: 181....
0
votes
3
answers
54
views
Python: Divide row in one DataFrame by all rows in another DataFrame
I have two DataFrames as follows:
df1:
A B C D
index
0 10000 20000 30000 40000
df2:
time type A B C D
index
0 5/2020 unit 1000 4000 900 ...
0
votes
2
answers
58
views
How to divide values of a column by each value of another column on a group-by-group basis
I am trying to figure out how to do this in R but would really appreciate some input on this. Let's say I have two dataframes, A and B:
dataframe A
a <- c("A", "A", "A"...
0
votes
1
answer
36
views
Rolling Ratio in Python Pandas
I'm trying to perform a rolling ratio between each couple of subsequent rows:
import pandas as pd
data = pd.DataFrame([1.0,2.0,3.0,4.0,5.0],columns=['close'])
The one underneath throws the following ...
3
votes
0
answers
31
views
How do I get the whole number when using "/" operator in python [duplicate]
Below is my code for a problem on leetcode:
for i in range(len(nums)):
ans =0
ans+=nums[i]
for j in range(i+1,len(nums)):
realans=0
ans+=nums[j]
realans= ans/k
...
1
vote
1
answer
56
views
Prolog - division
I am brand new to Prolog. Literally this week. I am looking to write a recursive Prolog predicate that accepts two numbers X, Y as input. It should output to screen a list of all numbers less than or ...
0
votes
1
answer
48
views
Big numbers in function in windows forms
im trying to do a function graph, its working but for some reason when i display function its giving me big numbers, i dunno why code looks fine to me, maybe i did something wrong with sample that i ...
1
vote
1
answer
47
views
Performing division with PostgreSQL / json
I have written a simple query against a table in a Postgres database that contains a column "manifest" of type json. Each cell contains a very long value and I am extracting the numerical ...
0
votes
0
answers
54
views
Is there any way to divide 64-bit integer by 10 on RARS?
I have been trying to divide two 32-bit registers by 10.
I know how to divide a register if a dividend is 32-bit like the following code, but I cannot solve if it's 64-bit.
div s8, s0, a6 # divide ...
2
votes
1
answer
28
views
Divide Dataframe Multiindex level 1 by the sum of level 0
I have created a DataFrame like this:
df = pd.DataFrame(
{
'env': ['us', 'us', 'us', 'eu'],
'name': ['first', 'first', 'first', 'second'],
'default_version': ['2.0.1','2.0....
0
votes
0
answers
22
views
easy level problem on online judge about Division (Python)
Problem: My solution code got TLE(3ms) in online judge, and I think my algo is too bad lol.
Hope someone can help to use more quick algo.
Firstly, data input N is an in ranging from 2 to 79 (2 <= N ...
1
vote
1
answer
38
views
I don't know why the division produces a quotient and a remainder that are wrong
How to fix this one: I don't know why both the quotient and the remainder are wrong.
My DOSBox Code:
.model small
.stack 100h
.data
Dividend db 0dh,0ah,"Enter Dividend : $" ;...
0
votes
1
answer
90
views
Power to n implementation that produces wrong results for negative exponent
In the following (naive) implementation of a pow(x, n) method, ignoring completely any optimized approach, I find the following problem:
public double pow(double x, int n) {
boolean negative = n &...
-1
votes
2
answers
33
views
How can I avoid errors when dividing by zero when using multiple lists
I have 2 lists with 4 values in each. These values will change every time the code is run.
probability = [4, 0.004e-2, 5.5, 0.0]
miss = [6954, 12507, 3621, 10440]
I have been plugging the lists into ...
2
votes
1
answer
257
views
How to declare Decimal place in RPGLE Fixed or in free format?
I don't have much knowledge in RPGLE. I am trying to solve this small exercise given to me. I never worked or seen exercises using decimals. I want to get percentage of 7 values. So, I want to do the ...
0
votes
1
answer
17
views
Dividing matrices with different number of rows and columns in R
I am not entirely sure if what I am trying to do is possible and googling isn't helping me a lot, so I decided to ask here. So, I have two matrices:
carrots <- matrix(sample(0:100,5), nrow=1, ncol=...
0
votes
0
answers
16
views
Integer division without changing data type [duplicate]
I am working division without changing data type.
int var1 = 7;
int var2 = 2.0;
float var = var1 / var2;
printf("%f", var);
for the first 2 line, var1 and var2 data types cannot ...
3
votes
1
answer
81
views
Multivariate polynomial division using Sage
I'm just starting to learn Sage and I'm trying to find some method to do polynomial divisions in several variables. An example of the calculations that I want to do can be the division of the ...
5
votes
2
answers
170
views
Is it possible to force Clojure into using primitive types instead of their boxed versions?
I have a following sample of code:
(type (apply / [5.0 0]))
It throws an unexpected error - "Division By Zero" (expected behavior: return Inf)
Probably, it happens due to auto-boxing - can ...
-1
votes
2
answers
55
views
calculating more the 19 digits of division
I want to make a python program that divides '1/7' in python however all I get is : 0.14285714285714285. How can I compute more digits after the decimal?
0
votes
0
answers
7
views
EMU8086 random number results [duplicate]
I have a homework on emu8086, the purpose is to calculate the total amount of scores from 3 inputs, and get the computed average. the problem is when the total of my input is not divisible by 3, ...
1
vote
1
answer
55
views
Goldschmidt division initialization using CKKS
I recently found out that I don't really understand how to make the initialization for goldschmidt division denoted in the following article: https://eprint.iacr.org/2021/914.pdf
It isn't really ...
0
votes
1
answer
73
views
Initial guess for Newton Raphson Division
Trying to use Newton’Raphson method to approximate the roots of f(x) = 1/x - D, which would be x = 1/D. This gives x_n+1 = x_n(2-D*x_n).
What would be a good initial guess for this? I saw on Wikipedia ...
1
vote
1
answer
54
views
Extract Evenly Divisible using recursive function
I am trying following program but I have done without sorting so someone would please help me that how to sort return output?
Given a array of numbers, and a single number n, return an
extracted array ...