Pergunta

I'm trying to understand the following algorithm:

int ubnd = Integer.MAX_VALUE
int lbnd = ubnd
while (fload)lbnd == (float)ubnd {
    lbnd = lbnd - 1
}
lbnd = lbnd + 1
print "$lbnd..$ubnd"

I don't see why for 63 iterations of the loop, we have (float)lbnd == (float)ubnd. It has something to do with the conversion of integers to floats, but I don't know what. I know that integers and floats both have 32 bits, but there must be a different way of storing them. Could someone help me out?

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a cs.stackexchange
scroll top