swift - Does converting UInt8(or similar types) to Int counter the purpose of UInt8? -


i'm storing many of integers in program uint8, having 0 - 255 range of values. later on summing many of them result able stored int. conversion have before add values uint8 int defeat purpose of me using smaller datatype begin with? feel faster use int, suffer larger memory footprint. why go uint8 when have face many conversions reducing of speed , increasing memory well. there i'm missing, or should smaller datatypes used other small datatypes?

you talking few bytes per variable when storing uint8 instead of int. these data types conceived on in history of computing, when memory measured in low kbs. apple watch has 512mb.

here's apple says in swift book:

unless need work specific size of integer, use int integer values in code. aids code consistency , interoperability. on 32-bit platforms, int can store value between -2,147,483,648 , 2,147,483,647, , large enough many integer ranges.

i use uint8, uint16 , uint32 in code deals c. , yes, converting , forth pain in neck.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo