-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numericshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors
Description
API Shape
To return 128 bit result (as per long BigMul(int a, int b))
partial class Math
{
ulong BigMul(ulong a, ulong b, out ulong low);
long BigMul(long a, long b, out long low);
}Use case
Manual multiply high is now being used for Dictionary
Which looks like
(uint)((((ulong)(uint)left * right >> 32) + (left >> 32) * right) >> 32)When ideally it would be
(uint)Math.BigMul(left, right, out _)Other langs
While it is what the asm does (i.e. RDX:RAX ← RAX ∗ SRC) the apis either use a 128bit value or the split pair.
MSVC:
__int64 _mul128(__int64 Multiplier, __int64 Multiplicand, __int64 *HighProduct)
__int64 __mulh(__int64 a, __int64 b)Others use * overloading on a __uint128_t type
scalablecory, danmoseley, itsamelambda, Daniel-Svensson, mcpiroman and 1 moredanmoseley
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numericshelp wanted[up-for-grabs] Good issue for external contributors[up-for-grabs] Good issue for external contributors