Skip to content

IsNegtive exist bug #462

@ChicChip

Description

@ChicChip

When using roaring64.BSI, due to value type is *big.Int , bsi's bitCount is Variable length even if some negative value is set. Thus there is a bug, when bsi's min negative value's bitLen is less than max positive num, GetValue will get wrong error.

testcode
bsi := roaring64.NewDefaultBSI()
for i:=-100;i<100;i++ {
bsi.SetValue(uint64(i+100),int64(i))
}
fmt.Println(bsi.GetValue(0))
result is -100, true

bsi := roaring64.NewDefaultBSI()
for i:=-100;i<1000;i++ {
bsi.SetValue(uint64(i+100),int64(i))
}
fmt.Println(bsi.GetValue(0))
result is 156, true

So if code uses len(b.bA) as sign bit may not work

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions