Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect values for the "or" function #290

Open
HoangNguyen219 opened this issue May 12, 2024 · 1 comment
Open

Incorrect values for the "or" function #290

HoangNguyen219 opened this issue May 12, 2024 · 1 comment
Assignees

Comments

@HoangNguyen219
Copy link

HoangNguyen219 commented May 12, 2024

Describe the bug
Incorrect values for the "or" function

Issue 1: Incorrect values
To Reproduce

    @Test
    fun testOr() {
        val a = BigInteger.parseString("-1")
            .or(BigInteger.parseString("11"))

        assertEquals(
            BigInteger.parseString("-1"),
            a
        )
    }
Expected :-1
Actual   :-11

Expected behavior
In java.math this test is successful:

    @Test
    public void testOr() {
        BigInteger a = new BigInteger("-1")
                .or(new BigInteger("11"));
        assertEquals(new BigInteger("-1"), a);
    }

Issue 2: When perform or function between a Number and Zero throw an exception
To Reproduce

    @Test
    fun testOr() {
        val a = BigInteger.parseString("0")
            .or(BigInteger.parseString("11"))

        assertEquals(
            BigInteger.parseString("11"),
            a
        )
    }
sign should be Sign.ZERO iff magnitude has a value of 0
java.lang.IllegalArgumentException: sign should be Sign.ZERO iff magnitude has a value of 0

Expected behavior
In java.math this test is successful:

    @Test
    public void testOr() {
        BigInteger a = new BigInteger("0")
                .or(new BigInteger("11"));
        assertEquals(new BigInteger("11"), a);
    }
@ionspin ionspin self-assigned this May 12, 2024
@ionspin
Copy link
Owner

ionspin commented May 12, 2024

Thanks for reporting, I'll give it a look when I have some free time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants