BNC.BAS DMS Science Fair, May 1997, June 1997 by Marc Kummel aka Treebeard. Contact mkummel@rain.org, http://www.rain.org/~mkummel/ About Treebeard's BigNum Cruncher: ----------------------------------- BigNum Cruncher is the newest program in Treebeard's Basic Vault (1997). BNC is a 16-bit Windows calculator program built around a homebrew library of big number arithmetic routines written with Visual Basic 3.0 under Win31. It features a large set of arbitrary precision decimal arithmetic procedures written in native BASIC with string operations. It can accurately crunch numbers up to 64K digits, given "world enough and time". BNC is a useful calculator with many features, including the unique ability to PLAY big numbers digit by digit as realtime MIDI sound events for Pythagorean algorithmic composition experiments. BNC is also a programmer's program, since all source code is provided. It will be useful for any Visual Basic programmer facing big number arithmetic tasks, who wants control over his tools. All source code is available for free use and study. No DLL required. You can simply drop the BNC.BAS code module into your program and crunch away! It's an engaging task to work out big number arithmetic algorithms in Basic, since we know them so well on paper. Any arithmetic operation can be done digit-by-digit to any desired precision. My aims are accuracy and to minimize string space; then speed. BNC is sometimes slow, but it gets there! This is not quite arbitrary precision since numbers, work, and answer must fit in available string space. But it's limited by system memory and time, not precision. This code can be much optimized (and less intuitive), but it works and makes sense. BNC is my first program for Windows, apart from the obligatory "Hello World". This program started small, with a cryptography project in mind, but it grew, maybe too much. I orginally wrote BNC for DOS with MS Basic PDS 7.10. This original code also runs in QB and Qbasic, but with much less work space. I've been happily programming DOS Basic for many years, and have resisted Windoze, but the time has come. This is a port of my original DOS code to Visual Basic 3.0. The DOS code is available in Treebeard's Basic Vault as BIGNUM and EVAL. *Sigh* It's typical that I've written my first Windows program just as 16-bit Windows is dying! BNC is a useful calculator with many features: ----------------------------------------------- * High precision arithmetic using familiar algorithms, accurate to 64K digits. * Full-featured expression evaluator. Type 2+3*4 and get 14. * Advanced math functions including rational roots and powers, logarithims and exponents, and trig and hyperbolic functions. * Number theoretical functions including modular arithematic and roots, factoring, and prime testing. * Convert decimals to ratios, with approximate roots and powers. * Number base conversions to base 64K. * BASIC-like scripting language with debugging support for repeated calculations and user-defined functions. * Unique ability to play big numbers digit-by-digit as realtime MIDI sound events for Pythagorean algorithmic composition experiments. * Informative Help with arithmetic glossary and information about computer arithmetic. (But it's not finished OR up to date!) * Full VB3 source code included for free use and study. Qbasic/QB/PDS DOS precursors of BNC are available from Treebeard's Basic Vault as BIGNUM.ZIP and EVAL.ZIP. The raw RTF Help files are also available from the Vault as BNCHELP.ZIP for those struggling with WinHelp. This will load into MS Word 6, and compile with HCP. BNC is easy and intuitive to use: ---------------------------------- * Type a number or Input Command in one or more Argument Box, or click an Input Button. * Select an Operation from the Operation Box or type a Key Shortcut. * Click on the Crunch Button to do the calculation. The result will appear in the Result Box. * Click on a Result Button to modify or save this result in various ways. * Click on an Action Button for additional actions including Factoring and Number Info, Number Base Conversion, Ratios and fractions, or MIDI output. These actions have their own windows. BNC is easy to install: ------------------------ There's no SETUP program since it's so easy to install BNC. Just unzip the archive to a directory and run BNC.EXE. It has a cool Treebeard icon that will appear if you add it to a Program Manager group. If BNC doesn't open, it's possible you don't have a Visual Basic support file that it needs. Check in \Windows\System for these files: CMDIALOG.VBX MCI.VBX SPIN.VBX MMSYSTEM.DLL VBRUN300.DLL These files are so common that I didn't include then in the archive to avoid bloat. They are available for download from all the usual places. Or send email and I'll return a copy. File list: ----------- Most of the files in the archive are source files - "the source, of course!" They can be deleted if you want, but they are my main reason for putting BNC on the Web, and I won't make it easy for you. Don't delete GENMIDI.TXT or the DAT files, but you can delete *.BAS, *.FRM, *.FRX, and the others below the line. One thing about VB over QB - it generates LOTS of files! BNC.EXE 16-bit executable BNC.HLP help file *under construction* BNPRMCNT.DAT prime number table GENMIDI.TXT general MIDI instrument names ADDNUM.BNC script: add numbers to n HI-LOW.BNC script: hi-low guessing game FIBO.BNC script: fibonachii numbers to n README.TXT this file TBVAULT.TXT about Treebeard's Basic Vault ------------ BNC4.MAK VB3 MAKE file BNC03.FRM + .FRX source: main form BNCABOUT.FRM + .FRX source: about box BNCBAS01.FRM + .FRX source: number base window BNCCMD01.FRM + .FRX source: command window BNCEXE01.FRM + .FRX source: execute window BNCFAC01.FRM + .FRX source: factor window BNCMAP01.FRM + .FRX source: MIDI map indow BNCMEM01.FRM + .FRX source: memory window BNCMID01.FRM + .FRX source: MIDI play window BNCPRG01.FRM + .FRX source: program window BNCRAT01.FRM + .FRX source: ratio window BNCSAY01.FRM + .FRX source: say window BNCSEQ01.FRM + .FRX source: MCI MIDI player OPENDLG.FRM source: OpenDialog control BNC03.BAS source: math routines BNCEVAL1.BAS source: eval and script routines BNCGLOB1.BAS source: global declarations MIDI_OUT.BAS source: MIDI stuff MIDI_CMD.BAS source: MIDI stuff BNC.ICO handmade Treebeard icon (32x32x16) PRIME01.BAS DOS QB source to build BNPRMCNT.DAT Conditions: ------------ This program and source code are yours to use and modify as you will, but they are offered as freeware with no warranty whatsoever. Give me credit, but do not distribute any changes under my name, or attribute such changes to me in any way. You're on your own! Send comments and fixes to: Marc Kummel aka Treebeard mkummel@rain.org http://www.rain.org/~mkummel/ For more interesting Basic software with source code, check out Treebeard's Basic Vault at http://www.rain.org/~mkummel/basic/