uint256 icon indicating copy to clipboard operation
uint256 copied to clipboard

Neg and Dec

Open ryansmith3136 opened this issue 1 year ago • 0 comments

Hi. Thank you for your code. This might be out of scope, but I wondered if Dec() should be prefixed with a "-" when Sign < 0.

package main

import (
    "testing"

    "github.com/holiman/uint256"
)

func TestDec(t *testing.T) {
    a := uint256.MustFromHex("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff")
    if a.Dec() != "-1" {
        t.Errorf("want: -1 got: %s", a.Dec())
    }
    b := uint256.NewInt(0).Neg(uint256.NewInt(1))
    if b.Dec() != "-1" {
        t.Errorf("want: -1 got: %s", b.Dec())
    }
}
--- FAIL: TestDec (0.00s)
    main_test.go:12: want: -1 got: 115792089237316195423570985008687907853269984665640564039457584007913129639935
    main_test.go:16: want: -1 got: 115792089237316195423570985008687907853269984665640564039457584007913129639935
    ```

ryansmith3136 avatar May 30 '24 21:05 ryansmith3136