LLM's think we should have language tuples!

Salih Dincer salihdb at hotmail.com
Sun Mar 30 11:45:23 UTC 2025


On Tuesday, 25 March 2025 at 04:44:15 UTC, Manu wrote:
> I asked Grok to write me a portable 64x64->128 multiplication 
> function in D to get the pattern, and this is what it wrote:
>
I think it was aware of Int128 and Claude.ai replied as follows:

```d
import std.int128;

auto mul64x64to128(ulong x, ulong y)
{
     uint x_low = cast(uint)x;
     uint x_high = cast(uint)(x >> 32);
     uint y_low = cast(uint)y;
     uint y_high = cast(uint)(y >> 32);

     ulong mul_ll = cast(ulong)x_low * y_low;
     ulong mul_lh = cast(ulong)x_low * y_high;
     ulong mul_hl = cast(ulong)x_high * y_low;
     ulong mul_hh = cast(ulong)x_high * y_high;

     ulong low = mul_ll;
     ulong high = mul_hh + (mul_hl >> 32) + (mul_lh >> 32);

     ulong mid = (mul_ll >> 32) + (mul_hl & 0xFFFFFFFF) + (mul_lh 
& 0xFFFFFFFF);
     low += (mid & 0xFFFFFFFF) << 32;
     high += mid >> 32;

     return Int128(high, low);
}
```

SDB at 79


More information about the Digitalmars-d mailing list