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

what is wrong about this script?

I am really confused what is exactly wrong. for first part of if the answer is always 0.0 , even separated part of formula are not 0. what is wrong here? import numpy as np def concpt(E,E0,theta): rad= theta*(np.pi/180) M=np.cos(rad) …
soha
  • 1
  • 2
-2
votes
1 answer

How does Python solve 6/-132?

In Python, 6/-132 gets an answer of -1, but should that be a 0? What's the rules behind it?
can.
  • 2,098
  • 8
  • 29
  • 42
-2
votes
4 answers

C++ wrong result of mathematical expression

I have to calculate some simple mathematical expression, but when I do it in one row, the result always will be zero. But the correct result is obviously not zero. And its interesting but when I separate the parts of expression, I get the correct…
Steve M. Bay
  • 313
  • 1
  • 3
  • 15
-3
votes
1 answer

Assembly language Division (Problems is getting the remainder)

jmp start mess1 db 'Enter 1st number: $' mess2 db 0a,0d, 'Enter 2nd number: $' nextline db 0a,0d, '$' start: mov ax, 03 int 10h mov dx, offset mess1 call printstring call input sub al, 30h push ax mov dx, offset mess2 …
-3
votes
1 answer

Why am I getting a "Segmentation fault (core dumped)" with basic division function?

The program is supposed to do integer division and show the remainder. It should check the if the denominator is 0 and allow the user to correct it. However, when the denominator is 0 and a non-zero integer is re-entered, I get a segmentation fault.…
-3
votes
3 answers

How to correct the division result in this MySQL query?

I have this table: CREATE TABLE `mytable` ( `id` int(11) NOT NULL, `value` longtext, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1; With this data: id, value -------------------- '1', '__cccccccc; Myword' '2', '__ddddddd;…
None
  • 281
  • 1
  • 6
  • 16
-3
votes
1 answer

Integer Division in Negative Numbers in Python

I'm testing big integers in Python; they are implemented as an object with sign and an array of digits. It's, basically, to describe Karatsuba Multiplication, and, for those big integers, I need the same behaviour like oridinary numbers with integer…
-3
votes
1 answer

How do I calculate change in number of coins?

"Given an amount of change less than one dollar, find the coins required to make up this amount. Your program should find the minimum number of coins. For example, if the change was $0.56, you would need 2 quarters, 1 nickel and 1 penny for a total…
-3
votes
1 answer

Order numbern in an array

I could use some help with a program for school in order to do so I need to put the position of the number in array: For example if I introduce 10582 the first position of the array is gonna be 2, the second 8, the third 5, the fourth 0, and the…
-3
votes
3 answers

How does an int variable change after being declared in a result of a statement as a double?

Let us say you have 2 declared variables, each being an integer. result = variable1 / variable2; result is a double. What would be the values of each of the variables after the previous statement executes? Let's say variable1 is 10 and variable2…
mpedzi03
  • 3
  • 4
-3
votes
2 answers

getting ZeroDivisionError: integer division or modulo by zero

I had written a simple pascal triangle code in python but I am getting a error def factorial(n): c=1 re=1 for c in range(n): re = re * c; return(re) print "Enter how many rows of pascal triangle u want to show…
Tanu Tanmay
  • 31
  • 1
  • 1
  • 5
-3
votes
1 answer

My program cannot break out of 'While Loop' when calculating # of divisors for a certain integer?

When I run the program in eclipse, I cannot break out of the while loop after the user enters a certain integer to move on and actually calculate the number of divisors it has and print it out with counts. /* * This program reads a positive…
Shaz
  • 1,443
  • 1
  • 27
  • 67
-3
votes
4 answers

recursion parameter issue

public void mystery1(int n) { if (n <= 1) { System.out.print(n); } else { mystery1(n / 2); System.out.print(", " + n); } } What gives this code for odd numbers. Becuase when we divide it it will not be an integer.
ferit enişer
  • 41
  • 1
  • 8
-4
votes
1 answer

Number of steps to reduce a number to zero leetcode problem

#include int main() { int num, count; count = 0; num = 8; while (num != 0) { if (num % 2 == 0) { // checks if num is even num = num / 2; count = count + 1; // increases counter…
Elachi
  • 3
  • 1
  • 3
-4
votes
2 answers

Why is this failing for just a corner case? Question link-https://www.hackerearth.com/problem/algorithm/chandu-and-his-interns/description/#c190148

Why is this failing for just a corner case? Question link-https://www.hackerearth.com/problem/algorithm/chandu-and-his-interns/description/#c190148 It ran fine for all the other cases. I took all the three cases where number of divisors could be…
Reetik Raj
  • 11
  • 2
1 2 3
41
42