int256 icon indicating copy to clipboard operation
int256 copied to clipboard

wrong Double to UInt256 conversion

Open Abalioha opened this issue 2 years ago • 1 comments

Issue can be easily tested with this snippet:

double d = 1E+20d;
UInt256 u = (UInt256)d; 
Console.WriteLine(u);   // 0

Abalioha avatar Aug 07 '23 10:08 Abalioha

The problem goes deeper to Lsh(in UInt256 x, int n, out UInt256 res) when in and out params are the same

        var u = new UInt256(1);
        UInt256.Lsh(in u, 1, out u);
        Console.WriteLine(u);   // 0

Abalioha avatar Aug 07 '23 10:08 Abalioha

Resolved by https://github.com/NethermindEth/int256/pull/44 and https://github.com/NethermindEth/int256/pull/43 with full tests for all parameters

benaadams avatar Feb 09 '25 07:02 benaadams