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

Wrong answer of average function?

I'm practically new to C programming and I've been trying to get a simple average function right, but the fractional part of the answer keeps messing up...?? #include #include float cal(int num1,int num2,int num3); int main(){ …
user3889963
  • 477
  • 3
  • 6
  • 17
0
votes
1 answer

Matlab uint8 division

I found in Matlab, uint8(n) / uint8(255) == 0 when n <127, while uint8(n) / uint8(255) == 1 when n >=127. I don't know how this happened. Since in C/C++, it should be 0 as long as numerator is less than denominator. Can anyone help me,…
wking
  • 1,293
  • 1
  • 16
  • 27
0
votes
1 answer

Unsigned division in nasm

I have been trying to debug a little assembly program where I ask for a dividend and a divisor and have to output the quotient and the remainder. For some reason however, my quotient and remainder are not output to the screen. Here is my…
O.A.
  • 171
  • 1
  • 11
0
votes
2 answers

How do I use modulus in a while loop to get individual digits of an integer?

I'm hoping to find a way to use a while loop (not a for loop) to get the individual digits of an integer put in through command line. Right now, I have it hard coded for how to get individual digits if a four digit integer is entered, but if I enter…
Bianca Fuller
  • 39
  • 1
  • 9
0
votes
4 answers

Understanding integral division

I have the following piece of code: public static final long KILOMETER_IN_METERS = 1000; public static int getKilometers(int distanceInMeter) { return (int) Math.floor(distanceInMeter / KILOMETER_IN_METERS); } And for the line with the return…
devger
  • 703
  • 4
  • 12
  • 26
0
votes
1 answer

Not the right result with Arithmetic Progression in C

Im trying to sum the multiples of a number (x0) with a progression number (r) and a number of times (n). If I use the number x0 = 6, r = 3, n = 3, the result should be 6+9+12=27, but the program gives me always 18. I try different times changing…
0
votes
1 answer

Math: Division Problems Generator

I am making a program that takes asks if you want to do Addition, Subtraction, Multiplication, and Division. It then asks how many questions. I have everything working but Division. I want to make sure that there will be no remainder when doing the…
0
votes
2 answers

VS C++ throwing divide by zero exception after a specific check

In the following C++ code, it should be impossible for ain integer division by zero to occur: // gradedUnits and totalGrades are both of type int if (gradedUnits == 0) { return 0; } else { return totalGrades/gradedUnits; //call stack points…
0
votes
2 answers

Setting a general rule for division

I have the following function: public static void main(String[] args) { int interval = 23950; System.out.println (Math.round(weekInterval/1000.00)*1000); } All the function does is rounding off the number (interval) to its…
User3
  • 2,465
  • 8
  • 41
  • 84
0
votes
2 answers

C atmega2560 Division of large integers

So I'm wondering about the costs of division on a atmega2560 as well as in general: Let's say I got something like this unsigned long long a=some-large-value; unsigned long long b=some-other-large-value; unsigned long…
VGD
  • 436
  • 1
  • 5
  • 25
0
votes
4 answers

Python - Split integer into individual digits (undetermined amount of digits)

We are reading lines from a file which contain integers. There are an indeterminate amount of lines being read. We must split each integer into the digits of the integer and then add the digits together and create another file which writes in both…
user3602484
  • 1
  • 1
  • 2
0
votes
2 answers

Multiply a fraction by 100 after div, to get the first two decimal places

Having a slight register problem with div using inline asm under vs2010. testScore and gradeScale are integers. _asm { mov eax, testScore //student's score - let's test 36 mov ebx, 40 //max possible score of 40 xor …
Arcath
  • 51
  • 6
0
votes
1 answer

Explicit powers of 2 in biginteger operations

I have a piece of code which goes like (vb.net or c# "language" is immaterial): Dim Counter As BigInteger = 0 Serial = BigInteger.DivRem(Serial, 4, Counter) CountersList.Add(CInt(Counter)) Since I was making many of those division by 4, with…
Pam
  • 474
  • 1
  • 4
  • 13
0
votes
3 answers

appending anything but a string to std::stringstream returns 0

Code in question: std::stringstream cd; int f = int((15 / allyCounter) * 100); cd << f; allyCounter is equal to 45. the idea is to get what percentage 15 is of allyCounter where allyCounter is a dynamic int that is…
Stephen K
  • 697
  • 9
  • 26
0
votes
2 answers

Problems dividing 64 bits in x86 Assembly

I keep getting 'Program received signal SIGFPE, Arithmetic exception' when dividing in x86 Assembly. It's confusing because the answer should be smaller than a 64 bit answer if I divide by 10.... mov $0x82b40000, $eax mov $0x21c3677c, $edx mov…
user2499298
  • 177
  • 2
  • 5
  • 17