You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When multiplying a BigInt 0 by a negative, basic type (e.g. -1 and cast(byte)(-1)), the resulting BigInt is -0 (negative zero), which creates unexpected behavior.
It is likely a logical error in the isIntegral!y variant of the mutating opOpAssign method (
); I imagine the linked conditional in opOpAssign should read something like if(y == 0 || data == 0UL) to prevent the sign being erroneously set for multiplication from 0, but I am not sure what the best modification should be.
conorobrien4god reported this on 2024-11-05T23:16:58Z
Transfered from https://issues.dlang.org/show_bug.cgi?id=24844
Description
Overview:
When multiplying a BigInt
0
by a negative, basic type (e.g.-1
andcast(byte)(-1)
), the resulting BigInt is-0
(negative zero), which creates unexpected behavior.It is likely a logical error in the
isIntegral!y
variant of the mutatingopOpAssign
method (phobos/std/bigint.d
Line 268 in 9771a24
opAssign
method (phobos/std/bigint.d
Line 524 in 9771a24
opOpAssign
should read something likeif(y == 0 || data == 0UL)
to prevent the sign being erroneously set for multiplication from0
, but I am not sure what the best modification should be.The appearance of
-0
(negative zero) appears to be a mistake, as evidenced by the resolved and fixed https://issues.dlang.org/show_bug.cgi?id=22771.Steps to Reproduce:
Tested in the latest version of D (DMD64 D Compiler v2.109.1) and on https://run.dlang.io/
MWE demonstrating the bug, and when it occurs:
The text was updated successfully, but these errors were encountered: