### How to round up the result of integer division?

I'm thinking in particular of how to display pagination controls, when using a language such as C# or Java. If I have x items which I want to display in chunks of y per page, how many pages will...

I'm thinking in particular of how to display pagination controls, when using a language such as C# or Java. If I have x items which I want to display in chunks of y per page, how many pages will...

Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> 2/2 1.0 Is this intended? I strongly...

I need to do a floating-point division in a dos batch. I didn't find a way to do it. Something like this : SET /A Res=10/3 returns a integer number. Is it possible to do it ?

In JavaScript, how do I get: The whole number of times a given integer goes into another? The remainder?

Can anyone tell me an efficient approach to perform the division operation without using '/'. I can calculate the integer value in log(n) steps using a method similar to binary search. 115/3 57 *...

How could I go about finding the division remainder of a number in Python? For example: If the number is 26 and divided number is 7, then the division remainder is 5. (since 7+7+7=21 and 26-21=5.)

Golang's math.Mod(10, 4) returns 2 -- ie. the integer part of division result 2.5 -- but shouldn't it be "the floating point remainder", that is, 0.5?

I need to represent some numbers in Java with perfect precision and fixed number of decimal points after decimal point; after that decimal point, I don't care. (More concretely - money and...

I've been looking around a good implementation of a simple python thread pool pattern and really can't find anything that suits my needs. I'm using python 2.7 and all the modules I have found...

I have a fixed-point bignumber library and want to implement fast factorial with no precision loss. After some math tricks on paper I got this formula: (4N)!=((2N)!).((2N)!).{...

Exercise from Deitel's "Java How To Program" 10th edition: 2.30 (Separating the Digits in an Integer) Write an application that inputs one number consisting of five digits from the user,...

I'm making a BigInt class as a programming exercise. It uses a vector of 2's complement signed ints in base-65536 (so that 32-bit multiplications don't overflow. I will increase the base once I...

I came across an interview questions and despite the fact I've been trying to solve it on my own I think I need some help. I've got an array of integer numbers (positive and negative) representing...

I'm trying to sort the digits of an integer of any length in ascending order without using Strings, arrays or recursion. Example: Input: 451467 Output: 144567 I have already figured out how to...

Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Follow each number by a space. Example output for userNum = 20: 20 10 5 2 1 #include <iostream> using...

According to Wikipedia, the modulo operator (remainder of integer division) on n should yield a result between 0 and n-1. This is indeed the case in python: print(-1%5) # outputs 4 In Ruby: puts...

I am trying to use a code to look for Wilson Primes for a bit of fun and to get me back into the swing of coding, however, I found that when I try to divide 172! +1 By 173 it gives me an Overflow...

How to catch exception from a child process in the parent process. The child process is created using Python's subprocess.Popen() like so: division_by_zero.py print(1/0) parent.py import...

I've searched half the day and found some very interesting things about using fixed point data types and bit shifting in C++ to accomplish division operations while avoiding floating point math....

I'm just started to work with Vectorcast and IAR for RL78 compiler. I want to build an environment in vectorcast using IAR Compiler for RL78 Microcontroller. Code which is used for testing has...

I have some code solving today's "Advent of code part 2". https://adventofcode.com/ I have currently many hardcoded modulo conditions, is there any simple way to reduce the number of...

my code (in the C language) is this: avg = round((r + g + b) / 3); r = avg; g = avg; b = avg; It should do the grayscale image effect. There are no syntax errors, but apparently avg, when...

If I understand correctly, the return value for floor division is always a whole number, even if the dividend and/or divisor are not whole numbers, so why does it not always return an...

The problem to solve is: Given a sorted list of integers of length N, determine if an element x is in the list without performing any multiplication, division, or bit-shift operations. Do this in...

I was working through this problem on leetcode https://leetcode.com/problems/leftmost-column-with-at-least-a-one/ and I cant think of an intuitive answer. Why is the right (or high) pointer...

Need MATLAB/Octave dec2base functionality function with independent bits/digits calculation algorithm (within integer logic, with no divisions, using modular arithmetic). Would be nice to have as...

I'm trying to find a way to implement EEA using uint64_t in C, on a system that will not support 128-bit integers. The problem is that it seems like there is always a case where some variable or...

I want to replace maximum value for each row in the column with mean value for this row. the method i am using taking a lot of time for complete. i am using pandas DataFrame. replaced mean value...

I have been trying out this problem on leetcode. *238.Product of array except self* Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the...

I want to get the exception of ZeroDivisionError: as 'integer division or modulo by zero' but I get as 'division by zero'.How can I get that. can anyone explain? a=int(input()) b=[] for i in...