longDiv

Calculate x86 long division of a and b.

longDiv
(
T
L
)
(
L a
,
T b
)
if (
is(T : long) &&
T.sizeof >= 2
&&
is(L == LongInt!T)
)

Examples

assert(longDiv(LongInt!int(1, 0), 1) == DivResult!int(1, 0));
assert(longDiv(LongInt!int(5, 0), 2) == DivResult!int(2, 1));
assert(longDiv(LongInt!int(0, 1), 0x1_0000) == DivResult!int(0x1_0000, 0));

assert(longDiv(LongInt!short(1, 0), short(1)) == DivResult!short(1, 0));
assert(longDiv(LongInt!short(0, 1), short(0x100)) == DivResult!short(0x100, 0));

assert(longDiv(LongInt!short(cast(ushort)-1, -1), short(-1)) == DivResult!short(1));
assert(longDiv(LongInt!ushort(cast(ushort)-1, 0), cast(ushort)-1) == DivResult!ushort(1));

version(X86_64)
{
	assert(longDiv(LongInt!long(1, 0), 1L) == DivResult!long(1));
	assert(longDiv(LongInt!long(0, 1), 0x1_0000_0000L) == DivResult!long(0x1_0000_0000));
}

Meta