{"action":"created","issue":{"url":"https://api.github.com/repos/Tornhoof/RoaringBitmap/issues/3","repository_url":"https://api.github.com/repos/Tornhoof/RoaringBitmap","labels_url":"https://api.github.com/repos/Tornhoof/RoaringBitmap/issues/3/labels{/name}","comments_url":"https://api.github.com/repos/Tornhoof/RoaringBitmap/issues/3/comments","events_url":"https://api.github.com/repos/Tornhoof/RoaringBitmap/issues/3/events","html_url":"https://github.com/Tornhoof/RoaringBitmap/issues/3","id":195231206,"number":3,"title":"Cadinality of 'full' bitmap seems to be broken","user":{"login":"ax0l0tl","id":2877925,"avatar_url":"https://avatars.githubusercontent.com/u/2877925?v=3","gravatar_id":"","url":"https://api.github.com/users/ax0l0tl","html_url":"https://github.com/ax0l0tl","followers_url":"https://api.github.com/users/ax0l0tl/followers","following_url":"https://api.github.com/users/ax0l0tl/following{/other_user}","gists_url":"https://api.github.com/users/ax0l0tl/gists{/gist_id}","starred_url":"https://api.github.com/users/ax0l0tl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ax0l0tl/subscriptions","organizations_url":"https://api.github.com/users/ax0l0tl/orgs","repos_url":"https://api.github.com/users/ax0l0tl/repos","events_url":"https://api.github.com/users/ax0l0tl/events{/privacy}","received_events_url":"https://api.github.com/users/ax0l0tl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-12-13T11:43:02Z","updated_at":"2016-12-14T08:56:55Z","closed_at":null,"body":"I'm using RoaringBitmap to back a search index implementation in .NET. Performance and memory usage is really impressive. Thanks for your work!\r\n\r\nI'm not very deep into the theory behind it, but I ran into a problem when working with 'full' bitmaps (all bits set). In my understanding bitmap represents a set of numbers in range [int.MinValue,int.MaxValue]. So Cardinality property of RoaringBitmap and RoaringArray should be of type long to be able to represent max cardinality of 2^32?\r\n\r\n```\r\n[Fact]\r\npublic void CardinalityOfFullSet()\r\n{\r\n    var full = ~Collections.Special.RoaringBitmap.Create();\r\n\r\n    Assert.Equal(Math.Pow(2, 32), full.Cardinality);\r\n}\r\n\r\n[Fact]\r\npublic void SerializeFullSet()\r\n{\r\n    var full = ~Collections.Special.RoaringBitmap.Create();\r\n\r\n    using (var ms = new MemoryStream())\r\n    {\r\n        Collections.Special.RoaringBitmap.Serialize(full, ms);\r\n        ms.Position = 0;\r\n        var rb2 = Collections.Special.RoaringBitmap.Deserialize(ms);\r\n        Assert.Equal(full, rb2);\r\n    }\r\n}\r\n```\r\n\r\nBoth above tests fail. In CardinalityOfFullSet cardinality is negative because of the unchecked add operation in internal constructor of RoaringArray. SerializeFullSet throws an OverflowException because in private constructor of RoaringArray the checked Linq Sum implementation is used.\r\n\r\nI just changed Cardinality property types on RoaringArray and RoaringBitmap to long. Serialization now works but the resulting cardinality of full bitset is 4294901760 not 2^32=4294967296 as I would have expected.\r\n"},"comment":{"url":"https://api.github.com/repos/Tornhoof/RoaringBitmap/issues/comments/266978810","html_url":"https://github.com/Tornhoof/RoaringBitmap/issues/3#issuecomment-266978810","issue_url":"https://api.github.com/repos/Tornhoof/RoaringBitmap/issues/3","id":266978810,"user":{"login":"ax0l0tl","id":2877925,"avatar_url":"https://avatars.githubusercontent.com/u/2877925?v=3","gravatar_id":"","url":"https://api.github.com/users/ax0l0tl","html_url":"https://github.com/ax0l0tl","followers_url":"https://api.github.com/users/ax0l0tl/followers","following_url":"https://api.github.com/users/ax0l0tl/following{/other_user}","gists_url":"https://api.github.com/users/ax0l0tl/gists{/gist_id}","starred_url":"https://api.github.com/users/ax0l0tl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ax0l0tl/subscriptions","organizations_url":"https://api.github.com/users/ax0l0tl/orgs","repos_url":"https://api.github.com/users/ax0l0tl/repos","events_url":"https://api.github.com/users/ax0l0tl/events{/privacy}","received_events_url":"https://api.github.com/users/ax0l0tl/received_events","type":"User","site_admin":false},"created_at":"2016-12-14T08:56:55Z","updated_at":"2016-12-14T08:56:55Z","body":"Ups, of course..."}}
{"actor":{"display_login":"ax0l0tl"}}