-
Notifications
You must be signed in to change notification settings - Fork 232
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
IsNegtive exist bug #462
Comments
Hello,
Can you add a unit test that reproduces the issue?
…On Wed, Nov 27, 2024 at 3:45 AM ChicChip ***@***.***> wrote:
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.
—
Reply to this email directly, view it on GitHub
<#462>, or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADZZAUXHT3GSMFANPE7NJV32CWICZAVCNFSM6AAAAABSSM5VLKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGY4TOOBZGY2DGNI>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
|
Are you attempting to set columnId to a negative value?
…On Wed, Nov 27, 2024 at 8:02 AM ChicChip ***@***.***> wrote:
1. unit test will pass
func TestGetNegativeValue(t *testing.T) {
num := int64(14)
bsi := NewDefaultBSI()
for i:=-num; i<=num;i++ {
bsi.SetValue(uint64(i+num), i)
}
val, _ := bsi.GetValue(0)
assert.Equal(t, -num, val)
bsi.SetValue(uint64((num+1)+num), num+1)
val, _ = bsi.GetValue(0)
assert.Equal(t, -num, val)
}
2. unit test will fail, when set value 16 to bsi, bsi's higthest bit
is not sign bit
func TestGetNegativeValue(t *testing.T) {
num := int64(15)
bsi := NewDefaultBSI()
for i:=-num; i<=num;i++ {
bsi.SetValue(uint64(i+num), i)
}
val, _ := bsi.GetValue(0)
assert.Equal(t, -num, val)
bsi.SetValue(uint64((num+1)+num), num+1)
val, _ = bsi.GetValue(0)
assert.Equal(t, -num, val)
}
Error: Not equal:
expected: -15
actual : 17
Test: TestGetNegativeValue
--- FAIL: TestGetNegativeValue (0.00s)
—
Reply to this email directly, view it on GitHub
<#462 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADZZAUTPTVSHT53FOZJRTDD2CXGHNAVCNFSM6AAAAABSSM5VLKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKMBTHE2TQMRWGM>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
no, in this code, you can see columnId is >=0, only value may a negtive number |
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
The text was updated successfully, but these errors were encountered: