Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
BooleanArray with size larger than 2147483647

I am trying to implement the sieve of Atkin in Kotlin. I want it to support numbers up to 2^32-1, so the sieve must be a UInt-indexed array.
I try to initialise the sieve like this:

var sieve = BooleanArray(limit + 1u)

Then, I get the error:

error: type mismatch: inferred type is UInt but Int was expected

So, is there any way of making a BooleanArray (or equivalent) store at least 4294967295 values?

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The most easy might be to use UInt as the size and then internally map 2 common BooleanArray, which use Int for addressing, despite there never could be a negative index value (this seems to be a design fault - or at least a lack of optimization). Which means, that one could as well address everything with signed Int. I mean, to internally map the negative values to one BooleanArray and the positive values to another one BooleanArray. The actual problem seems to be, that a signed Int is being passed, but only the positive range (50%) can be used to address data. One could use absoluteValue, because it doesn't matter in which direction the array is being filled.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!