mkTulip 1.0 Manual

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted. The author makes no representations about the suitability of this software for any purpose. It is provided "as is" without express or implied warranty. By use of this software the user agrees to indemnify and hold harmless the author from any claims or liability for loss arising out of such use.


mkTulip 1.0 - A Totally Unoptimized Large Integer Processor for Tcl 8.



mkTulip, the Totally Unoptimized Large Integer Processor, lets you do integer arithmetic with very long integers. Similar to the Unix tool "bc" there is virtually no limitation to the number of digits an integer value can have, and there is no 32 or 64 bit boundary and such.

mkTulip provides only one command, "tulip", which can be called in two ways: either with one or three arguments, see below. Also see the Notes
section for information on value length limitation.


tulip Value1 Operand Value2

Performs a basic arithmetic or comparison operation and returns the result. Allowed operands are *, /, +, -, <, >, <=, >=, ==, and !=. The unary operator - is not supported, but the expression "0 - Value" is equivalent.

tulip Expr

Calculates and returns an expression that can have an arbitrary number of operands, values and parenthesis pairs. Expr must be a proper list, where each parenthesis, value and operand is a list element. The unary operator - is not supported, but the expression "0 - Value" is equivalent.


Maximum Value Length

The actual maximum number of digits a value can have is guaranteed to be at least 1000. It is specified in a #define statement in mkTulip10.c and can be changed easily. This setting only influences the size of the call stack during execution of the tulip command. Heap memory is not allocated.

The statement "at least 1000" comes from the fact that the maximum length of the result is determined before the expression is actually computed. an overflow error is raised if this number exceeds the interal buffer length (currently 1024 minus 1), even if the actual result would not be as long. 1000 digits are always guaranteed, though.


  % tulip 123 + 45678
  % tulip 1234567890987654321 * 998877665544332211
  % expr 9876543 * 12345
  1666839047                           <-- Overflow!
  % tulip 9876543 * 12345
  % tulip 1234567890987654321 < 998877665544332211
  % tulip 1234567890987654321 >= 998877665544332211
  % tulip { 123 + 45678 / ( 33 - 2 * 8 ) }
  % tulip { 2323437434536943 * 42472034723 / ( ( 5676544 + 2342 ) * ( 2342 - 23423490076 ) ) }



mkTulip is written in C and comes with a DLL for Windows. On Unix, the package needs to be compiled into a shared library first (see below). mkTulip works with Tcl/Tk version 8.0 and higher. It has been stubs-enabled with version 8.2.

To install, place the directory "mkTulip1.0" in one of the directories contained in the global Tcl variable "auto_path". For a standard Tcl/Tk installation, this is commonly "c:/program files/tcl/lib" (Windows) and "/usr/local/lib" (Unix).


To compile the package, just provide the correct path to "tcl.h" and link against "tcl8x.lib" (Windows) or "" (Unix) respectively. If you use stubs, define USE_TCL_STUBS and link against "tclstub8x.lib" (Windows) or "libtclstub8x.a" (Unix) instead.

For Visual C++, the following command should work:

  cl /I c:/progra~1/tcl/include /D USE_TCL_STUBS /c mkTulip10.c
  link c:/progra~1/tcl/lib/tclstub83.lib /dll mkTulip10.obj

On Linux 2.2, this here works fine:

  gcc -shared -DUSE_TCL_STUBS -ltclstub8.3 -o mkTulip10.c


Test the installation by opening a tclsh or wish and entering "package require mkTulip". The string "1.0" should appear. If it fails, "cd" into the directory "mkTulip1.0" and load it directly with "load ./mkTulip10.dll" (Windows) or "load ./" (Unix). If no error occured, it succeeded and something must be wrong with the location of "mkTulip1.0".


No changes - Initial version.


Michael Kraus