Slowly I study Swift and after the lesson by type there was a question regarding Int. It is written that for devices with a 32 bit processor Int from -2147483648 to 2147483647. And for 64 bit from -9223372036854775808 to 9223372036854775807. Actually the question is one, but with sub-questions:
- How to use it correctly?
1.1 What will happen if, as a result of any calculations, a number greater than 2147483647 is obtained on a device with a 32-bit processor? The number is not particularly large.
1.2 If the numbers are guaranteed to be in the range from -2147483648 to 2147483647, does it make sense that there will be such big limits on 64 bit? In the same place, something seems to be connected with memory allocation, will it require more resources / slower work?
int 32 бита, if you need more, then uselong longfarther - long. It is safer. The speed of work will be about the same (the processor will still process it in 1 clock). If you need to fix the size, it is better to use something like uint32 and so on ... - pavel