Minimizing .EXE Size by Avoiding Floating Point Math (90895)



The information in this article applies to:

  • Microsoft Basic Professional Development System for MS-DOS 7.0
  • Microsoft Basic Professional Development System for MS-DOS 7.1
  • Microsoft Visual Basic for MS-DOS

This article was previously published under Q90895

SUMMARY

Because of the granularity of the run-time library for PDS versions 7.0 and 7.1, you can minimize the size of your .EXE file in programs that do not require floating point math by avoiding the use of functions that require the floating point math package.

MORE INFORMATION

Programs written in PDS that use or contain routines that can use floating point math may be up to 10K larger than an equivalent program that does not require the floating point math package. Below is a list of techniques to help reduce the need for the floating point math package in a program

  • Use integer variables whenever possible.
  • Use integer division using the (\) operator whenever possible.
  • Avoid the use of Basic statements that use the floating point math package. Some Basic statements that use floating point math such as SIN, COS, and TAN are obvious. However you will also want to avoid the use of the not-so obvious statements that use floating point math such as DRAW, INPUT, PMAP, POINT, PRINT USING, RANDOM, READ, SOUND, TIMER, VAL, and WINDOW.
Below are two very small Basic programs and their .EXE file sizes. They are intended to illustrate the memory savings that can be gained from avoiding the inclusion of the math package when it is not required.

Example

'Program that does not use floating point math. Size: 10000 bytes
I% = 1
PRINT "I% ="; I%
END

'Program that uses floating point math. Size: 21438 bytes
I! = 1
PRINT "I! ="; I!
END
				

REFERENCES

"Programmer's Guide," Basic PDS versions 7.0 and 7.1, Chapter 15

Modification Type:MinorLast Reviewed:8/16/2005
Keywords:KB90895