Skip to content

math/big: AndNot(x,y) doesn't work when x is positive and y is negative #9609

@randall77

Description

@randall77

package main

import (
"fmt"
"math/big"
)

func main() {
fmt.Println(new(big.Int).AndNot(big.NewInt(0xff), big.NewInt(-1)))
}

This should print 0. It does print 2.
The bug is in math/big/int.go:893, it should use sub, not add, as the comment in the previous line specifies.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions