660 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
2
votes
1
answer
187
views
Is it possible to call x86 `idiv r/m8` from MSVC2022 using C++ directly?
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;
...
2
votes
2
answers
187
views
Where is GCC's __divti3 defined?
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 ...
6
votes
1
answer
267
views
Speeding up integer division with doubles
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 ...
1
vote
0
answers
151
views
How can I handle overflow in bigint / int signed division with x86 idiv?
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 "ient[4],int32_t &remainder). My algorithm is:
...
2
votes
0
answers
51
views
record accumulate round error for integer divisions to reduce final error
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 ...
4
votes
2
answers
237
views
How to get specified number of decimal places of any fraction?
So I can generate many tuples like this:
(...
0
votes
0
answers
150
views
Question about Knuth's Algorithm D for division
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, (...
33
votes
1
answer
4k
views
Why does a = a * (x + i) / i; and a *= (x + i) / i; return two different results?
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 ...
1
vote
1
answer
129
views
Bug in the normalization step of Knuth Algorithm D (TAOCP 4.3.1)?
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 ...
1
vote
0
answers
111
views
Why Java's int division rounds to zero? [duplicate]
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 ...
1
vote
1
answer
59
views
Overflow error in VBA calculation (division)
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 ...
0
votes
1
answer
110
views
Divide 8-byte stored in 2 uint32 by a uint32 it on a machine with 32-bit operation
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 ...
1
vote
1
answer
107
views
Having a hard time getting an accurate quotient when running a binary division program
My program keeps producing incorrect quotients. What do you think is wrong with it?
This is the code:
divide proc
; Set cursor position for PROMPT_1
mov ah, 02h
mov bh, 00h
mov dh, 0Bh ...
1
vote
0
answers
50
views
Why is floor division inconsistent with division follow by floor, e.g. 1//0.2 = 4.0 [duplicate]
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:
>>> ...
6
votes
1
answer
4k
views
Different types of Integer division in Python
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 ...