The Number Crunching Page

by Chris Williams

This page has been visited times since August 4, 1997

Welcome to my home page! I live in the beautiful city of Pietermaritzburg in the province of KwaZulu-Natal, South Africa, where I have spent most of my life. I went to Merchiston Preparatory School and St. Charles' High School in the 1960s, and the University of Natal in the 1970s. In the early 1980s I was a founder of the Pietermaritzburg Amateur Computer Club, and I obtained a B.Sc. Degree in Computer Science at the University of South Africa (UNISA) in 1981.

I have been working (and playing!) with computers for the last 20 years, and have always been fascinated by the advances made in desk-top computing over this period - especially "number crunching". See some interesting facts and figures about the incredible progress in Floating Point calculations below, and download some of my programs and utilities. If you are a Borland/Turbo Pascal 6 or 7 programmer, there are routines to speed up your math code - see MATH387. Also see my Calculating Pi page.

Progress over the last two decades

The rate of progress in the speed and accuracy of numerical calculations over the last two decades almost defies belief. What would have taken hours or even days on a humble 8-bit Z80 based desk-top computer in the mid 1970s will now execute in a fraction of a second on a Pentium II machine, which can be purchased for even less than the earlier machine!

Floating Point hardware

In the early days, hardware to do floating point calculations simply wasn't available on desk-top machines. In those days, you had to make do with a set of software routines, which executed very, very slowly. The advances in floating point hardware, coupled with massive advances in execution speed have lead to the really spectacular advances in overall floating point speeds, as this diagram shows. These are approximate figures, some of which I have recorded myself over the years. The last column shows how long it would take to compute a problem which involves 16 million floating point operations (FLOP stands for FLoating point OPerations per second):

Floating Point Performance

Year CPU Type Speed Approx. FLOPS Time to compute problem
1976 Z80 2-Mhz 350 12 Hours
1981 8088 4.77-Mhz 1,000 4.4 Hours
1983 8088+8087 4.77-Mhz 30,000 8.9 Minutes
1985 80286+80287 8-Mhz 41,000 6.5 Minutes
1987 386DX+387 16-Mhz 270,000 1 Minute
1991 486DX 33-Mhz 1,400,000 11.4 Seconds
1993 Pentium 60-Mhz 7,500,000 2.13 Seconds
1995 Pentium 133-Mhz 16,000,000 1 Second
1997 Pentium II 266-Mhz 40,000,000 0.4 Seconds

See how the biggest gain was the introduction of the 8087 co-processor. Also note that the 80287 was actually a poorer performer than the 8087 at the same clock speed! The above figures are very approximate, and are based on a mix of multiply, divide, subtract and add operations in well-written code. I have not actually had the opportunity to test a Pentium II, so that figure is a bit of a "guess-timate" based on what I have read.

Calculating Pi

Even though maths is not one of my strong points, I enjoy fiddling with formulas and algorithms by programming them. I recently came across some of the latest formulas for calculating Pi to incredible precision - see Calculating Pi.

Free Software

I have knocked together a number of little programs over the years, mainly written in Pascal. I started with Turbo Pascal 2 back in 1985, and I now work with Borland Delphi 2 (I haven't yet tried version 3). Most people see Delphi as a RAD tool (similar to Visual Basic), but to me it is more the latest version of Borland Pascal.

Here are some programs you can download. Most are just "fun", and some are rather trivial, so please treat them as such. Also, some are not yet complete. They have been virus checked, and I will update them from time to time. You will need to "unzip" them after downloading - if you don't have an unzip program, get WinZip here.

All these program are copyright (c) Chris Williams, 1997. They are "freeware". You may distribute them to others as you please.


Windows 95/NT Only :-

After unzipping, simply run each .EXE file, or make a shortcut to it. There's no installation, and they don't touch Windows or the Windows Registry in any way at all, so they are very safe to run. To "uninstall", just delete the .EXE file.

CURVFIT (168kb) - Interactive graphing of a set of X,Y values using Splines, Lagrange polynomials, Regression, Exponential, Log and Power fits. Has the unusual feature of being able to grab a point with the mouse and move it around to see how it affects the shape of the fit - great for isolating bad readings in a set of measured values! (This program is still under development).

KEEPDISK - (coming soon!) Keeps a hard disk running. Since I leave my PC on 24 hours/day for voice/fax, I use Power Management to shut down the hard disk and monitor after 15 minutes idle. Trouble is, I find the delay restarting the hard disk while I am working very irritating. Rather than continuously changing BIOS/Windows settings, I wrote this very simple program to access the disk every few minutes, which effectively disables the shutting down of the hard disk. Put it in the Startup group, and simply close it down or run it again to disable / enable. Overhead is negligible.

CALCPI (117kb) - This program simply calculates Pi to the limits of IEEE extended precision (about 18 decimal places) using a number of amazing formulas that I found on the Web. I have included the source, because this may be more interesting than actually running it! Calculating Pi is a fascinating subject.


DOS :-

After unzipping, simply run each .EXE file in DOS or from the DOS prompt.

FLOPIO (52kb) - This consists of three programs. FLOPIN and FLOPOUT work together like the DISKCOPY command. FLOPIN reads the entire contents of a floppy disk to a file on the hard disk, and FLOPOUT writes the file back to a floppy. Supports all standard floppy disk formats, 160k to 2.88Mb. Can be useful for archiving or backing up old floppy disks. Can also read and write "non-DOS" floppies, so long as they have an IBM standard sector format (e.g. Unix disks from Minix or Linux). The third program, EXTRACTF, recreates the files from a FLOPIN run. This allows you to read a floppy with FLOPIN, and just keep or archive the floppy image file. Then you can use EXTRACTF to extract the files.

PURIFY (9kb) - This program "cleans up" an ASCII text file (typically .TXT). It creates a new file with all non-visible and graphic characters removed, corrects all invalid combinations of CR and LF, and truncates lines to a specified length. PURIFY is great if you are having trouble viewing or printing a file from another source, e.g. UNIX (it does everything that "unix2dos" does and more), or for files in other formats, even .EXE files etc. After going through PURIFY, a file can be printed with no side effects on just about any printer, or loaded into just about any text editor.

BYTEANAL (8kb) - This program analyses the range of byte values in a file. It shows the least common and most common byte values, as well as a break down of all characters into common categories, e.g. upper and lower case letters, digits, graphics, etc. If you are not sure what a file is, BYTEANAL can give you useful clues.


TURBO/BORLAND PASCAL v. 6/7 PROGRAMMERS :-

After unzipping, view the file MATH387.DOC, which explains how to use MATH387.

MATH387 (50kb) - This is a set of inline functions to greatly speed up some of the built-in math functions. Borland's compilers only generate 8087 code, but today the vast majority of PCs are at least 486DX and up which has the 387 "co-processor" built in with an enhanced set of instructions. If your program is targeted only to run on these platforms, it seems silly to generate 8087 code! The 387 introduced an enhanced range of instructions, in particular covering sine, cosine and certain other transcendental functions in hardware. For example, sines and cosines execute three to five times faster, while tangent executes eight to ten times faster than the fastest Turbo Pascal coding of sin(x)/cos(x)! Exponentiation (x^y) is also available as fast inline code. Here is a demo program which illustrates the speed improvement possible on your PC!

Also included are 32-bit integer multiply and divide functions. These are especially useful if you are using Turbo Pascal version 6, because Borland implemented longint division as a slow library routine with shifts. With MATH387, longint division is ten times faster! In version 7, Borland also implemented 32-bit multiply and divide, but even so, the MATH387 routines are somewhat faster because they are inline.

I have not tested these functions in Delphi 1. They are not required for Delphi 2 - the superb 32-bit Delphi 2 compiler generates optimal code!


This page hosted by Get your own Free Home Page
Any comments, suggestions, or ideas? Please contact me! Chris Williams