Skip to main content
Filter by
Sorted by
Tagged with
2 votes
1 answer
183 views

I am trying to call idiv r/m8 using MSVC2022's current Microsoft Visual C++ Compiler 17.4.33403.182 and C++. Using the most straightforward approach: struct cdiv_t { // char std::int8_t quot; ...
JohannesWilde's user avatar
2 votes
2 answers
169 views

For GCC's __int128 type __int128 div128(__int128 a, __int128 b) {return a / b;} GCC will generate a call to __divti3 instead of inline assembly. So where is this actually defined? Github's search ...
qwr's user avatar
  • 11.6k
6 votes
1 answer
265 views

I have a fixed-point math-heavy project and I was looking to speed up integer divisions. I tested double division with SSE4 and AVX2 and got nearly 2x speedup versus scalar integer division. I wonder ...
M.kazem Akhgary's user avatar
1 vote
0 answers
142 views

I have a serious problem I really want to solve. I am trying to implement void operator divide(uint32_t dividend[4],int32_t divisor,uint32_t &quotient[4],int32_t &remainder). My algorithm is: ...
user13947194's user avatar
2 votes
0 answers
50 views

It is well-known that integer division can result in errors, no matter which rounding method is used (we use Floor rounding below as example). Moreover, if division is calculated multiple times (with ...
wub's user avatar
  • 525
4 votes
2 answers
232 views

So I can generate many tuples like this: (...
Ξένη Γήινος's user avatar
0 votes
0 answers
145 views

I want to implement Knuth's Algorithm D for division on C (Link to Knuth's book, p272). In step "D4. [Multiply and subtract.]", it states: if the result of this step is actually negative, (...
Daan's user avatar
  • 39
33 votes
1 answer
4k views

I am calculating the number of routes possible in a 20 * 20 grid from top left to bottom right when only down and right moves are possible. I read about calculating the central binomial coefficient to ...
user29150577's user avatar
1 vote
1 answer
123 views

Knuth Algorithm D, during the normalization step (D1), states to set d to (b-1)//v_hi where b is the basis (word size or half-word size) and v_hi is the upper limb of the denominator. Then multiply ...
Duncan Townsend's user avatar
1 vote
0 answers
108 views

I've found that the rule for rounding two int in Java is to get the value closer to 0. Which mean that if you divide two positive numbers, you get the "floor" value e.g 7/3=2. And if you ...
arso's user avatar
  • 2,367
1 vote
1 answer
59 views

In the macro below I get an Overflow error when calculating Rate = cell.Offset(0, 7).Value / cell.Offset(0, 2).Value - regardless of whether Rate is declared as Long or Double. Kindly help to identify ...
cdfj's user avatar
  • 167
0 votes
1 answer
108 views

I want to divide uint64 by a uint32 in WebGPU, which currently only handles uint32 operations. So I am trying to simulate this by storing my long into two uint32 buffers high and low. and now I want ...
RRR's user avatar
  • 529
1 vote
0 answers
45 views

The operator // for integer division is called "floor division" in the python documentation, but comparing to other floor implementations there is a discrepancy, for example: >>> ...
Jonatan Öström's user avatar
5 votes
1 answer
4k views

In terms of the resulting value (ignoring the resulting data type), are the following the same in Python if x and y are both numbers? int(x / y) x // y If so, which is better to use in real ...
user2526586's user avatar
  • 1,342
1 vote
1 answer
1k views

I wanted to implement the restoring division algorithm (without using the div operation) in RISCV assembly language. The algorithm I have to implement is the following . I implemented this, but it is ...
gabibbo quinto's user avatar
0 votes
0 answers
29 views

I have a function that needs to support both py2 and py3, unfortunately. Currently, there's a division op: n = a / b a and b are usually whole numbers, but represented as floats, but from what I can ...
24n8's user avatar
  • 2,328
4 votes
1 answer
234 views

This question arose when I looked into the efficient implementation of the MRG32k3a PRNG on 32-bit processors without, or slow, support for double computation. I am particularly interested in ARM, ...
njuffa's user avatar
  • 27.1k
3 votes
1 answer
182 views

Revisiting 32-bit integer division on AVR 8-bit processors, I tried to code unsigned non-restoring division. Not thinking it looks too bad, there is one problem: With a divisor with highest bit set, ...
greybeard's user avatar
  • 2,677
0 votes
3 answers
291 views

I am trying to divide two decimals and want to get the exact integer part of the result only using a\b. Consider the following example: Dim a, b As Integer a = 200 b = 2 ...
maponda1's user avatar
-3 votes
4 answers
267 views

How to compute ⌊𝑥÷𝑐⌋ for a variable integer 𝑥 and a fixed-point rational number 𝑐≥1 precisely? The input 𝑥 ∈ [0, INT_MAX] is stored in a variable of type int, 𝑐 ∈ [1, INT_MAX] is given as a ...
AlMa1r's user avatar
  • 1
1 vote
2 answers
69 views

id client_id driver_id city_id status request_at 1 1 10 1 completed 2023-12-23 2 2 11 1 cancelled_by_driver 2023-12-23 3 3 12 6 completed 2023-12-23 4 4 13 6 ...
jingchun liu's user avatar
1 vote
0 answers
164 views

Given a positive integer n, I wish to find the longest unique sequence of positive integers, none greater than n, such that for every pair of adjacent numbers in the sequence one is an integral ...
TWTom's user avatar
  • 17
1 vote
1 answer
305 views

I get a SIGFPE exception when dividing by 0 in x86 assembly using idiv. How would I disable it from assembly? Do I need a syscall or can it be done directly in x86? Reproduction: test.asm default rel ...
Basic Block's user avatar
2 votes
1 answer
97 views

I'm tackling the credit problem from cs50 and I'm baffled by the for loop on one section because I'm dividing a long integer 4003600000000014 by 100 and it returns a large negative number -1685133312. ...
GohanHango's user avatar
1 vote
1 answer
78 views

I have this piece of code from my project. It is taking all the amount from the transaction and adding it and showing how much you earned in the day. The problem is it's not showing in decimal format ...
Salik Syed's user avatar
6 votes
1 answer
4k views

What is the easiest way to do integer division in PowerShell? So that the arguments are integers and the result is also an integer. In C++ it would be e.g. 115/10.
Dr. Gut's user avatar
  • 3,335
0 votes
2 answers
381 views

I am programming an interface on this Nextion display. Specifically, I am trying to program a digital dial that rotates around a centre point. These screens are great, but they don’t have any trig ...
Eman's user avatar
  • 303
0 votes
2 answers
587 views

I've got this task: dividePower2 Compute x/2n, for 0 ≤ n ≤ 30. Round toward zero. Argument 1: x Argument 2: n Examples: dividePower2(15,1) = 7 dividePower2(-33,4) = -2 This is what I've got so far ...
Aidan M's user avatar
  • 47
1 vote
1 answer
835 views

I am trying to create a code which would take as input 1 8-bit number in HEX form and produce the decimal equivalent. Here is my code: data segment msg1 db 10,13, "Give me a valid hex ...
Cerise's user avatar
  • 111
-3 votes
1 answer
92 views

Nums = range(1,60) def is_prime(Nums): for x in range(2, Nums): if (Nums%x) ==0: return False return True prime_numbers = list(filter(is_prime,Nums)) Print(prime_numbers)...
Nani Selase's user avatar
0 votes
0 answers
5k views

I am trying to follow the division algorithm for signed numbers (2's complement representation) based on the algorithm described here. This is the standard restoring method with M and AQ registers ...
mahmood's user avatar
  • 25.2k
6 votes
5 answers
653 views

What would be the simplest formula to implement int divround(int a, int b) {...}, in C, where output is a/b with banker's rounding (round half to even)? For example, divround(3,2) and divround(5,2) ...
Abarajithan's user avatar
2 votes
1 answer
381 views

I'm trying to create a code which divides a uint64_t by another uint64_t plus it applies rounding to the result. The code should be as fast as possible and work for all inputs (e.g. I would prefer it ...
Kevin Meier's user avatar
  • 2,644
0 votes
0 answers
78 views

I've seen that gcc does a great job in optimizing integer divisions with a constant divisor. E.g. uint64_t f(uint64_t x) { return x / 1000; } uint64_t f2(uint64_t x) { return x / 10000; } ...
Kevin Meier's user avatar
  • 2,644
2 votes
1 answer
71 views

Suppose you want to divide -198077031546722079779 by 23 using gas. As this dividend is larger than %rax, how do you put it in %rdx:%rax? All the books I read on assembly avoid illustrating idiv with ...
ntos's user avatar
  • 379
1 vote
0 answers
57 views

Based on the method in this question Using 2's Complement to Perform Binary Division for Signed Number , I tried to calcuate 12 / 10, which is 0000 1100 / 0000 1010 , but with its method I got ...
Rick's user avatar
  • 7,664
3 votes
1 answer
108 views

The 8086/8087/8088 MACRO ASSEMBLY LANGUAGE REFERENCE MANUAL (c) 1980 Intel Corporation mentions (Emphasis mine): ... the 8087 provides a very good approximation of the real number system. It is ...
Sep Roland's user avatar
  • 41.2k
0 votes
1 answer
165 views

Division and Multiplication part doesn't work. It jumps in to the prompt of the 2nd input number. I ran the code the addition and subtraction part work, whereas the division and multiplication doesn't ...
Suwaaaa's user avatar
  • 11
0 votes
0 answers
161 views

I tried using the below assembly code to get the quotient and remainder for IDIV instruction, but it didn't work as expected. I use NASM as the assembler. It prints "The quotient is: -...
Daniel's user avatar
  • 11
0 votes
0 answers
86 views

I got my answer of imul How do you manually calculate imul -1 * 3? but now run into idiv. For unsigned division, I simply use long division and can get the correct result. 50/4: 1100 ...
Rick's user avatar
  • 7,664
0 votes
4 answers
345 views

I want to make sure if a number in register is a multiple of 3 using AVR Studio and assembly language but on AVR ATmega 8515 so there is no div instruction/syntax I already tried a couple method like ...
Muhammad Hafiz's user avatar
0 votes
2 answers
87 views

When dividing somewhat large integers with numbers that divides them, I get different results from division / and floored division //. for instance: In [1]: a = 123456789012345678 In [2]: int(a/2) ...
topcat's user avatar
  • 189
1 vote
1 answer
706 views

I am making a script to backup databases in SSMS from Powershell. I want to add a progress bar since these databases take some time to backup. This is what I have. The progress bar is popping up but ...
movement's user avatar
1 vote
1 answer
69 views

If we have a number in a register and we need to get its decimal digits values - it's easy. All we need is divide the number by 10 and save the remainders we get. lp: cmp eax, 0 ; have we ...
Fyodor's user avatar
  • 185
-3 votes
1 answer
141 views

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 ...
JOHN PHILIP ILUSTRISIMO's user avatar
0 votes
2 answers
95 views

Is it a bug, or there's some official document that says, that this was supposed to happen?? Because my C program worked very well.
Cyber World's user avatar
0 votes
1 answer
255 views

I'm trying to implement an integer division with rounding. Obviously, by default integer division does floor and I was thinking I could use the remainder to determine if I should add 1 to my result. ...
spizzak's user avatar
  • 1,167
2 votes
0 answers
140 views

While using Godbolt Compiler, I was playing around with various functions when I checked what signed division looks like using the following code: int div10(int num) { return num / 10; } Where ...
Dory L.'s user avatar
  • 133
0 votes
3 answers
914 views

I'm trying to divide number into groups in plain python without importing or the use of if-statements, and get the division into groups + remainder forming one extra group so that 200 / 99 would be 3, ...
Xebbexebbe's user avatar
-1 votes
3 answers
339 views

So I am trying to figure out how to divide the given amount of people into given group sizes for example: 11 people into groups of 3, and the program giving the answer 4, since the remainder should ...
Nohahhex's user avatar

1
2 3 4 5
14