Long integers are the most efficient numeric data type in PowerBASIC and should be used in all cases where speed is important and a greater numeric range is not required. (Using Byte and Integer variables in FOR/NEXT loops is actually slower than using a Long integer.)
I am wondering:
(a) whether that advice applies equally to variables used in general arithmetic operations as it does to loop-counter variables.
(b) and, if so, at what point (if any) does the extra memory requirement of a large program in which all integer variables are converted to longs negate the increase in execution speed intended to be gained from this kind of optimization.
(c) would the advice to go long even extend to integer variables used as pseudo-booleans -- i.e. with values of only zero, representing false and NOT zero (-1), representing true. The difference being that these are not generally used in arithmetic but only tested for equality to zero or non-zero.
(d) And what about floating-point arithmetic? Is it also faster using double precision variables (#) as opposed to single precision (!) The PB documentation is silent on this.
I am writing a program with a lot of arithmetic-calculation routines executed multiple times. Mostly integer arithmetic in which about 80% of the variables used are integers. I'm trying to get an idea as to whether it is worth the effort to convert all my integers to longs. (I use type-identifier suffixes on all my variables.)
Comment