Quote:

> Using CLNG() produces longer source code (but may execute faster) than my

> original suggestion of multiplying variables and constants by 1&.

It will certainly execute faster, since QuickBasic doesn't optimize enough

to notice that you're multiplying by a constant 1, and therefore calls the

runtime library's 32-bit multiplication routine. CLNG(x%) requires only

two simple (and fast) machine instructions:

MOV AX, x% ;Load x% into the AX register

CWD ;Convert Word in AX to Doubleword in DX:AX

If the longer source code really bothers you, you could add 0& instead of

multiplying by 1&. QB actually optimizes this - it realizes that it

doesn't really have to add zero, just convert to a long integer, so you

get exactly the same code as CLNG().

Of course, then you run into precedence issues, since addition has lower

precedence than a number of other operators. The only way this could

work without paying *any* attention to precedence is to convert every

integer variable x% into a parenthesized expression of the form (x% + 0&),

and that's hardly short or elegant.

(Not to mention the fact that adding 0& really wants a comment to explain

what you're doing, while CLNG() is pretty much self-explanatory.)

Quote:

> Apparently, the answer to my orignial question of whether there is a

> simple or elegant means to force an entire expression to be evaluated in

> long integer format without worrying about the internal structure of the

> expression is no.

Maybe I'm missing something, but "use CLNG() on any integer inside the

innermost set of parentheses" seems pretty simple to me.

---

Glen Blankenship Hudsucker Industries