# Data types: Should I always use double for numbers?



## Jaymond Flurrie (May 16, 2010)

According to Professional Excel Development Second Edition pages 573-574, Excel internally use doubles. So should I always use doubles no matter what I do with numbers - if I need to use small numbers, like something between 1 and 200, I would choose data type byte for that, is it still better to a double there? Is the only reason not to use double that when you see double, you immediately think "oh, here we have big decimal number"?


----------



## Joe4 (May 17, 2010)

What I have always been taught is to choose the smallest possible data type for the job, as it is my understanding that choosing Double when something like Byte or Integer would do could potentially slow down your code, as using Double uses more memory.

I don't know if that excerpt you posted implies that even though I choose Integer, Excel is going to use Double anyway.  It may be that it just uses the Double data type in calculations, but as for storing values to a variable, I think it still uses whatever data type you have declared the variable as.

Even if Excel *really* stored every numeric variables "behind the scenes" as Double too, it certainly does no harm to declare the variable with the appropriate Data Type.  At the very least, it gives the programmer/user an idea as to the nature and size of the variable being used.


----------



## SydneyGeek (May 20, 2010)

Adding to Joe's comments...

If you're putting values onto worksheets they will become Doubles.
For counters in loops and other processing I use Long. You could use Integer but I read somewhere (forget the ref now) that Long Integer is processed faster than Integer -- something to do with internal defaults. 
I also tend to manipulate currency values as Currency data type, because Currency is a decimal (Double is a binary) and therefore more accurate for decimals than Double. 

Denis


----------

