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

How do assemblers handle a value that is separated on 2 registers (e.g EDX:EAX)?

I'm trying to understand how do assemblers handle these. Currently I'm trying to learn to code assembly by writing an assembly code manually. But I'm wondering how to handle a product that is separated by EDX:EAX after the operand "MUL". What if I…
MDuh
  • 415
  • 1
  • 7
  • 19
0
votes
3 answers

how to write script to round up in python

If 33 people with 33 cars show up to a carpool parking lot, how many cars will be needed if each car can hold 4 people? How many cars will be left at the parking lot? I know the answer is 9 but how do I write the script for that. I have been…
Boaz
  • 13
  • 1
0
votes
3 answers

Keep getting 0 as an output in C# division

I'm trying to divide a random number that is generated by 13. It can range from 1, 53. I need to divide the random number 13 to get a whole number (to determine what suit it is in a deck of cards). I need the suit to be out of 1-4. Random…
user3158491
  • 45
  • 1
  • 1
  • 5
0
votes
3 answers

C: converting Farenheit to Celsius

int main (void) { int fahrenheit; // fahrenheit stands for fahrenheit double c; // c stands for celsius printf("Enter your fahrenheit, we'll covnvert it into celsius! "); scanf("%f", &fahrenheit); c = 5/9 * (fahrenheit - 32); …
user2223285
0
votes
1 answer

How to divide minute by 3 in PHP ?

How to divide time by 3? I know $minute%3==0 could work if minute is 0,3,9,12,15... But how to judge if minute is 1,4,10,13,16, if minute is 2,5,11,14,17? Thanks. $minute = date('i'); if($minute%3==0){ //if minute is 0,3,9,12,15...do…
cj333
  • 2,547
  • 20
  • 67
  • 110
0
votes
0 answers

Dividing mpz_t variables to give double

I have two mpz_t type variables containing large integers and I need one divided by the other as a double. I know that this double will be <1, but I can't find a way to do this. Also, is it normal for mpz functions to use huge amounts of memory? I…
zylatis
  • 448
  • 3
  • 14
0
votes
1 answer

Simple x86-64 division not working

For a simple test case for my compiler project, I'm trying to divide 88 by 11, but when I call idivq my program throws a Floating Point Exception. Here is the relevant section of generated code where the exception occurs: # push 88 movq $88,%r10 #…
Otto45
  • 555
  • 2
  • 6
  • 20
0
votes
2 answers

Trouble with calling method

public static void main (String[] args) { for (double f=0; f<=20;f++) { System.out.println(f+":Degrees Fahrenheit converted to Celsius = "+ celsius(f)); } } public static double celsius (double fahrenheit) { double…
Sagun
  • 11
  • 3
0
votes
2 answers

how can I use printf() and mod operation to get a decimal when my instance variables can only be Ints

So I'm missing something here. I have a method that is supposed to compute and return the value of a stock portfolio. but it uses a mixed number which has a dollars portion and an eighths portion public class StockPortfolio { //Instance Vars …
PeterLion
  • 5
  • 4
0
votes
3 answers

Java Fractions, again

Yesterday, I attempted to do this one way...today I am trying another and I am still stuck. I have to find a way of doing this using integer division and mod. Here is my code followed by the error messages. public int evaluateFraction(int w, int n,…
Java Newb
  • 101
  • 1
  • 1
  • 7
0
votes
2 answers

How to use modular division?

I am practicing out of a book, self study. It is blowing my mind. If someone could help me ? How do I subtract the amount of the first, second and third bag as well as collect the total number of bag? The project asks these criteria > Assignment…
0
votes
2 answers

Floating Point Exception (Core Dumped) while doing division in assembly

I'm trying to add 2 two-digit numbers which are bound to yield a two-digit or three-digit number. Here's what I have so far, and when I try to print the carry, it says Floating Point Exception (Core Dumped) section .data msg db "Enter 2 numbers:…
Kevin Lloyd Bernal
  • 355
  • 3
  • 8
  • 24
0
votes
2 answers

Optimizing Division by Unknown Denominator Without Using Division Operator

I am trying to write a C function that performs the following calculation at runtime: Numerator/Denominator where: Numerator is a prior calculation result, is always positive, and is greater than the Denominator and, Denominator is such that (1 <=…
0
votes
2 answers

When dealing with integer division, is there a way to collect like terms?

For example, when NOT working with integer division the following is true x/4 + x/2 = x*(1/4+1/2) = x * 3/4 When dealing with integer division is there a way to reduce x/4 + x/2 into this form: x * (int1/int2)? If so, how?
0
votes
4 answers

c program to divide a number and show mod of a number won't work

Hi I made a program which integer divides a number by 50 and shows the mod of that number also but the compiler tells me that "value requires left operand of assignment" for"/" I'm not sure what to do. Here's the code: #include int…
user2147550