Skip to content

Approximated Size returns 0 for a saturated bitset on amd64 #104

Open
@rotemiman

Description

@rotemiman

It seems that Go's behavior when casting Positive Infinity to uint32 is architecture specific. This causes theApproximatedSize calculation to return an inconsistent value between architectures.

If you run this:

saturatedBloom := bloom.FromWithM(bitset.New(10000).Complement().Bytes(), 10000, 4)
fmt.Println(saturatedBloom.ApproximatedSize())

In amd64, it prints 0, while if you run it on arm64, it prints the max value for uint32.

For a smaller example:

fmt.Println(uint32(math.Inf(1)))

Is equivalent.

I'd expect a saturated bloom to return a very high number and not zero, so I'd propose checking first for a saturated bloom and returning max uint32 explicitly.

See: golang/go#56023

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