Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

102
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda