Skip to content
Merged
Changes from 27 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b889996
The current implementation of powmod is very slow for the ulong type …
Aditya-132 Mar 18, 2025
f860160
some imports changes
Aditya-132 Mar 18, 2025
7fc002d
made asm functions for mulmod and
Aditya-132 Mar 18, 2025
43c35de
changes made for x86 32 bits system
Aditya-132 Mar 18, 2025
394af25
Merge branch 'dlang:master' into issue-#10513
Aditya-132 Mar 19, 2025
e1cb9a9
implmented the given changes
Aditya-132 Mar 20, 2025
d58ac9d
fixing styleing
Aditya-132 Mar 20, 2025
dafec4d
Implmented changes in review
Aditya-132 Mar 20, 2025
c036af6
Merge branch 'dlang:master' into issue-#10513
Aditya-132 Mar 21, 2025
7ca9b77
revied changes
Aditya-132 Mar 21, 2025
ef53e0c
changes in function title
Aditya-132 Mar 21, 2025
fb04cca
some minute changes
Aditya-132 Mar 21, 2025
776880c
testing on why it failed on Alpine x64 system
Aditya-132 Mar 21, 2025
1411386
styling changes
Aditya-132 Mar 21, 2025
6abb199
updated reviewed suggestion
Aditya-132 Mar 22, 2025
3a02c67
changes made as per reviewd suggestions
Aditya-132 Mar 22, 2025
5f11dbd
removing low variable
Aditya-132 Mar 22, 2025
2e67c29
removed extra conditions
Aditya-132 Mar 23, 2025
23dffa7
Merge branch 'dlang:master' into issue-#10513
Aditya-132 Mar 24, 2025
933d72f
added method with core.int128
Aditya-132 Mar 24, 2025
2bf559a
removed line 61 to 65
Aditya-132 Mar 24, 2025
ef8a738
styling changees
Aditya-132 Mar 24, 2025
dfcfb4c
styling changes
Aditya-132 Mar 25, 2025
8f643bb
changes udivmod implementaion
Aditya-132 Mar 25, 2025
71a1e9f
removed Cent from mul operation
Aditya-132 Mar 26, 2025
4f79940
changed to Cent(lo: c)
Aditya-132 Mar 26, 2025
6e7531c
changes as per review
Aditya-132 Mar 26, 2025
c8a2400
indentation changes
Aditya-132 Mar 27, 2025
6d6fad6
indentation changes
Aditya-132 Mar 27, 2025
bced460
Merge branch 'dlang:master' into issue-#10513
Aditya-132 Mar 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 24 additions & 18 deletions std/math/exponential.d
Original file line number Diff line number Diff line change
Expand Up @@ -830,28 +830,34 @@ if (isUnsigned!F && isUnsigned!G && isUnsigned!H)
{
static if (T.sizeof == 8)
{
static T addmod(T a, T b, T c)
if (c <= 0x100000000)
{
b = c - b;
if (a >= b)
return a - b;
else
return c - b + a;
T result = a * b;
return result % c;
}

T result = 0, tmp;

b %= c;
while (a > 0)
else
{
if (a & 1)
result = addmod(result, b, c);

a >>= 1;
b = addmod(b, b, c);
import core.int128 : Cent, mul, udivmod;
auto product = mul(a, b);
if (product.hi >= c)
product.hi %= c;
T remainder = void;
udivmod(product, c, remainder);
return remainder;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this being rendered wrong or is indentation missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done with correction

}
else static if (T.sizeof == 4)
{
if (c <= 0x10000)
{
T result = a * b;
return result % c;
}
else
{
DoubleT result = cast(DoubleT) (cast(DoubleT) a * cast(DoubleT) b);
return result % c;
}

return result;
}
else
{
Expand Down
Loading