Skip to content

Incorrect values for the "or" function #290

Open
@HoangNguyen219

Description

@HoangNguyen219

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);
    }

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions