Integer arithmetic is always faster if done properly. The problem is that SuperBASIC stores constants as float, so when you do i%=i%+1 it first has to convert i% to float, add 1 using float arithmetic, then convert the new value back to integer and store it in i%, which is of course a waste of time. Minerva solved this by introducing integer tokenisation so that constants which will fit into an integer are indeed stored as integer so no conversion to float is needed when doing arithmetic (unless you get overflow or mix them with floats of course). Thus, on Minerva, programs which use lots of integer arithmetic will run a little faster and take up less space (notably with lots of numeric DATA statements).tcat wrote:Ah, that explains that nicely. So what QL does is actually clever, keeping select & loop variables in FP, that way is faster in the interpreter.
Real benefit of integers is perhaps smaller space allocated on stack or heap, as TG says, integers take words, floats take exponent(word)+mantisa(long), i.e. 2bytes versus 6bytes.
With the storage and processing power currently available, there probably isn't much to be gained from using integers. Modern processors have integrated FP arithmetic capabilities and even if emulators like QPC2 wouldn't make use of them the speed penalty would probably not be noticable.
Jan.