Short vs Int and Float vs Double

Mahares

Expert
Licensed User
Longtime User
In most of the threads I read including mine, I seldom see Short or Float used to DIM variables. Instead I see Int and Double, particularly when SHORT and FLOAT are sufficient. In the scheme of things, devices have more memory and are faster. Is that the reason? or is it insignificant that it does not make an impact. Can someone give a reason that substantiates using the correct one.

Byte : 1byte signed: -128 to 127
Char : 2bytes unsigned: 0 to 65535 : not all values are valid Unicode code points
Short : 2bytes signed: -32768 to 32767
Int : 4bytes signed: -2147483648 to 2147483647
Long : 8bytes signed: -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 (9.2...E+18)
Float : 4bytes +/- 3.4e +/- 38 (~7 digits)
Double : 8bytes +/- 1.7e +/- 308 (~15 digits

Mahares
 

Jost aus Soest

Active Member
Licensed User
Longtime User
I personaly prefer Int and Float...

Mmmm...

Maybe because both types uses 4 bytes aka 32 bit, promising fastest processing by low memory usage. The "shorter" types often are aligned to 4 bytes ("padding"), but I'm not sure for Android OS.

But for arrays normaly I use the "shortest" type possible to save memory.
 
Upvote 0
Top