digitalmars.D - Cent/ucent why should we implement?
- Richard (Rikki) Andrew Cattermole (12/12) Aug 14 Another monthly meeting has occurred, this time one of the things
- kinke (5/6) Aug 14 Emphasis on 'in the language', as opposed to a library type like
- Mindy Batek (0xEAB) (3/4) Aug 14 Straightforward C bindings and importC.
- monkyyy (4/5) Aug 14 Lincoln was a very important president and it will help D become
- Johan (7/12) Aug 14 Perhaps Amaury can chime in. I remember he improved a few LLVM
- Doigt (7/19) Aug 30 While it is a superficial reason, I believe it must be stated
- Dukc (13/18) Aug 31 It isn't really any added language complexity from design or user
- Luna (4/16) Sep 05 Makes writing float/double parsers far easier given then you can
- Guillaume Piolat (2/4) Sep 06 Clock conversion in video needs 64-bit * 64-bit => 128-bit result
Another monthly meeting has occurred, this time one of the things I presented was for my PR to implement cent/ucent. The reception was not the warmest, with questioning on why to do it. Does anyone have reasons for they may want it in language? Mine: - Some basic arithmetic can only be described using double the word-size type, like with overflow, without using intrinsics. - Atomics use it for cas - SIMD types go above word-size. Has anyone got any other reasons? https://github.com/dlang/dmd/pull/23575
Aug 14
On Friday, 14 August 2026 at 16:27:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Does anyone have reasons for they may want it in language?Emphasis on 'in the language', as opposed to a library type like (existing) `std.int128.Int128`, or its `core.int128.Cent` low-level foundation.
Aug 14
On Friday, 14 August 2026 at 16:27:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Has anyone got any other reasons?Straightforward C bindings and importC.
Aug 14
On Friday, 14 August 2026 at 16:27:50 UTC, Richard (Rikki) Andrew Cattermole wrote:my PR to implement centLincoln was a very important president and it will help D become the future of banking along with all the barrow checking work
Aug 14
On Friday, 14 August 2026 at 16:27:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Another monthly meeting has occurred, this time one of the things I presented was for my PR to implement cent/ucent. The reception was not the warmest, with questioning on why to do it. Does anyone have reasons for they may want it in language?Perhaps Amaury can chime in. I remember he improved a few LLVM 128bit codegen things, clearly because he needed it. (cryptography/hashing, I suppose) cheers, Johan
Aug 14
On Friday, 14 August 2026 at 16:27:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Another monthly meeting has occurred, this time one of the things I presented was for my PR to implement cent/ucent. The reception was not the warmest, with questioning on why to do it. Does anyone have reasons for they may want it in language? Mine: - Some basic arithmetic can only be described using double the word-size type, like with overflow, without using intrinsics. - Atomics use it for cas - SIMD types go above word-size. Has anyone got any other reasons? https://github.com/dlang/dmd/pull/23575While it is a superficial reason, I believe it must be stated anyway: because it's cool and D is a cool language that always has the coolest features. It may sound silly, but being cool is part of D's core appeal as a language. With that said, I hope you had a good laugh.
Aug 30
On Friday, 14 August 2026 at 16:27:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Another monthly meeting has occurred, this time one of the things I presented was for my PR to implement cent/ucent. The reception was not the warmest, with questioning on why to do it. Does anyone have reasons for they may want it in language?It isn't really any added language complexity from design or user perspective, because all it's rules are reused from `byte`/`short`/`int`/`long`. We need all the language rules for built-in integers, `cent` or no `cent`, so we might as well have it. It probably does make sense to _internally_ implement it in DRuntime so that the user can swap or leave out its implementation without using a custom compiler, but having a language keyword to actually use that implementation is only consistent with how other integer types are used, especially as we already have a keyword pair reserved for that.
Aug 31
On Friday, 14 August 2026 at 16:27:50 UTC, Richard (Rikki) Andrew Cattermole wrote:Another monthly meeting has occurred, this time one of the things I presented was for my PR to implement cent/ucent. The reception was not the warmest, with questioning on why to do it. Does anyone have reasons for they may want it in language? Mine: - Some basic arithmetic can only be described using double the word-size type, like with overflow, without using intrinsics. - Atomics use it for cas - SIMD types go above word-size. Has anyone got any other reasons? https://github.com/dlang/dmd/pull/23575Makes writing float/double parsers far easier given then you can assume that the compiler implements 128 bit values correctly
Sep 05
On Sunday, 6 September 2026 at 02:03:09 UTC, Luna wrote:Makes writing float/double parsers far easier given then you can assume that the compiler implements 128 bit values correctlyClock conversion in video needs 64-bit * 64-bit => 128-bit result
Sep 06
On Sunday, 6 September 2026 at 10:33:15 UTC, Guillaume Piolat wrote:On Sunday, 6 September 2026 at 02:03:09 UTC, Luna wrote:This is already available in the registers. You just need to copy it out: ```d ulong[2] mul128(const ulong u, const ulong v) safe pure nogc nothrow { ulong[2] r; if(!u || !v) return r; version(D_InlineAsm_X86) { asm trusted pure nogc nothrow { mov R8, r.ptr; mov R9, v; mov RAX, u; mul R9; mov [R8], RAX; add R8, 8; mov [R8], RDX; } } else // without asm we have no access to the high bits of the result { // this is awfully slow (4 multiplications, 6 additions and 8 shifts) // but during CTFE this will only increase the compilation time // so maybe acceptable enum m = uint.max; ulong t; t = (u & m)*(v & m); r[0] = t & m; t = (u>>32)*(v & m) + (t>>32); r[1] = t>>32; t = (u & m)*(v>>32) + (t & m); r[0] += (t<<32); r[1] += (u>>32)*(v>>32) + (t>>32); } return r; // r[1] contains the high bits of the product, r[0] the low bits (big endian) } ``` But at least, this function should be in Phobos.Makes writing float/double parsers far easier given then you can assume that the compiler implements 128 bit values correctlyClock conversion in video needs 64-bit * 64-bit => 128-bit result
Sep 07
On Monday, 7 September 2026 at 10:38:42 UTC, Dom Disc wrote:But at least, this function should be in Phobos.In druntime since v2.112: https://dlang.org/changelog/2.112.0.html#druntime.int128, https://dlang.org/phobos/core_int128.html#.mul.2
Sep 07









kinke <noone nowhere.com> 