[AccessD] Integer v. Long

Stuart McLachlan stuart at lexacorp.com.pg
Mon Sep 5 04:21:08 CDT 2022


Nope. It's a matter of efficiency.

In a 32bit or 64bit operationg system (Access and WIndows) the OS uses 32 bit  registers to 
manipulate integral values. Every time you use a 16 bit integer, the OS has to handle the 
translation to from 32bit.

Bottom line - Longs are more efficient, especially for things like large loops.


On 5 Sep 2022 at 4:15, Arthur Fuller wrote:

> Frequently I encounter code (most often in samples but sometimes also
> in examples, and even in code made available for public consumption)
> in which the developer declares numeric variables as Long rather than
> as Integer. This practice strikes me as a lazy habit.
> 
> Data Type Low Range High Range Storage Requirement (bytes)
> Integer -32,768 32,767 2
> Long -2,147,483,648 2,147,483,647 4
> 
> Granted, if storage and performance were critical, one would probably
> not code in VBA. But for most practical purposes in VBA, it seems to
> me that Longs are overkill.
> 
> Opinions?
> --
> Arthur
> -- 
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
> 




More information about the AccessD mailing list