Questions tagged [integer-division]

Anything related to the integer division operation, i.e. that special form of division which is performed between two integer numbers and which in math results in a quotient and a remainder. This is mostly relevant for languages which have specific integer data-types, for which the division is an integer division, or for languages having a specific operator/function to perform integer division.

Anything related to the integer division operation, i.e. that special form of division which is performed between two integer numbers and which in math results in a quotient and a remainder. This is mostly relevant for languages which have specific integer data-types, for which the division is an integer division, or for languages having a specific operator/function to perform integer division.

619 questions
0
votes
2 answers

Integer Division with random.randint

When using random.randint() in this form, I can't get integer division to work: (random.randint(-40, 215) - -40) // (215 - -40) This returns 0, however something like this returns correctly: random.randint(3,5) - 2 // 2 How do I format the first…
WMueller
  • 61
  • 2
  • 11
0
votes
2 answers

Division as input parameter returning 0

So I'm trying to input a division problem as a parameter, and I am always getting 0 when the answer is < 1. I know why this is happening but I'm not sure how to fix this so it gives a decimal answer. def division(x): print x Where "x" is 1/2…
Kramer M.
  • 1
  • 1
0
votes
1 answer

Modulo 2 division using Decimal (used in CRC )

1010000/1011 using Binary Modulo 2 Division remainder is 011. i.e 80/11 remainder =3. I know how to do it in binary but how can I calculate above result using decimal values 80 and 11.
Kanika
  • 9
  • 4
0
votes
1 answer

What's the right way to implement integer division-rounding-up?

It's very common to need to divide integers but get the result rounded up rather than down. For a while now, I've been using the following function for that mini-idiom: template constexpr inline S div_rounding_up(const S&…
einpoklum
  • 118,144
  • 57
  • 340
  • 684
0
votes
2 answers

Python3 Stop division for large floats

I am dividing extremely large integers, so to speak up to 1kb integers and I ran into 2 problems already. Either OverflowError: integer division result too large for a float or The float is rounded off to some digits and when I try to multiply…
Got To Figure
  • 390
  • 6
  • 13
0
votes
1 answer

Android divisions always results in 0

Please check the below android code private void preMealChartCreator(int numberOfPreMealLow, int numberOfPreMealNormal, int numberOfPreMealHigh, int totalReadings) { Log.d("OverViewFragment","chart_low: "+numberOfPreMealLow+"…
PeakGen
  • 21,894
  • 86
  • 261
  • 463
0
votes
4 answers

Explain how binary operators could be used to coerce floating point number to integer number in JavaScript

In JavaScript there is no special type for integer values. Actually, all numbers has a Number type which is Double Precision Floating Point Number (IEEE 754) i.e. binary64. One of the problems with numeric operations in JavaScript is that there is…
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
0
votes
1 answer

Division between two numbers in a Dataframe

I am trying to calculate a percent change between 2 numbers in one column when a signal from another column is triggered. The trigger can be found with np.where() but what I am having trouble with is the percent change. .pct_change does not work…
J Westwood
  • 421
  • 1
  • 9
  • 22
0
votes
2 answers

Python 2 decimal division unexpected results

I am trying to do the calculation Using the python decimal module with the following code: from decimal import * getcontext().prec = 9 sum = Decimal(0) for i in range(1,11): sum += Decimal(1/(i**4)) print sum however, this outputs 1, not a…
kalenpw
  • 695
  • 3
  • 10
  • 34
0
votes
2 answers

Division that rounds down rather than truncates

I need to align real values divided by some positive constant to nearest lower integer, regardless of their sign. Example are ( here the backslash represents my desired operator) 21,5 \ 2 = 10 -21,5 \ 2 = -11 52,3 \ 2 = 26 -52,3 \ 2 = -27 Is there…
Charles
  • 988
  • 1
  • 11
  • 28
0
votes
1 answer

x86 Assembly - idiv to get decimal places

I'm limited to using the .386 with my current process. Using intel x86 how do I get the decimal places of a division? Basically I want it to output to the hundredth place like: 12.81 Here is my current code: mov AX, Dividend cwd idiv…
LearningProcess
  • 607
  • 1
  • 8
  • 29
0
votes
1 answer

How To Popup whole Div without changing its content position

I want to popup the whole div that contain image,div,etc . but problem is that when i popup div the position of within div is changed. i want to zoom the div that display like popup and cover the whole page. when i click on div the div should be…
0
votes
0 answers

Java conversion code - why does the division not return the same result?

Beginner question. This might be more of a math problem, I sorted the code out, but I have no idea why the solution works. Please help explain: As you may know, the formula for coversion from Celsius to Farenheit is F=C*9/5+32 Now, I am trying to…
0
votes
1 answer

Issue with simple division in SQL Server

I must be a total idiot or something. I'm using Microsoft SQL Server 2008. I can't do simple division. SELECT 200/600 returns a big fat goose egg (0.00). Yet if I do 600/200 it returns 3. The only thing I can think of is some server setting. I'm…
Gregbert
  • 121
  • 1
  • 11
0
votes
1 answer

Hardware for "A div B" with A and B fixed point

I need a way to compute how many times a fixed point number B is contained into a fixed point number A. Something like integer division but on non-integer operands. I need to design an hardware block for this operation. My first guess is to use…
KBowser
  • 31
  • 3