xl
Precision
Get Your Numbers Right
Using xlPrecision In Your
Programming Code
Visual Basic Projects, Excel VBA Macros,
Etc.
You can use xlPrecision in your programming code, such as Visual Basic projects, Excel VBA macros, Word VBA macros, any other application's VBA macros, or from any other code that can call a COM (ActiveX, OLE) server.
As a developer, you can freely distribute the free edition of xlPrecision to your users.
Here's an example:
Dim Oxlp As Object
Dim strRet as String
Set Oxlp = CreateObject("xlPrecision.cls_xlPrecision")
strRet = Oxlp.xlpDIVIDE(67,89,,,,,50)
Debug.Print strRet
Set Oxlp = Nothing
Alternatively, if you prefer Early Binding, you could set a reference (in
Excel's VBE, choose Tools | References) to xlPrecision, and do this:
Dim Oxlp As xlPrecision.cls_xlPrecision
Dim strRet as String
Set Oxlp = CreateObject("xlPrecision.cls_xlPrecision")
strRet = Oxlp.xlpDIVIDE(67,89,,,,,50)
Debug.Print strRet
Set Oxlp = Nothing
Note that Early Binding probably won't be a major advantage with the kind
of work xlPrecision does, and it may require removing and recreating the
reference when new versions of xlPrecision are installed in the future.
Important Note:
To maintain high precision, the return value must always be a String data type,
and never converted to any numeric data type. High precision is automatically
lost upon any conversion to any numeric data type.
In addition, if the return value is placed into an Excel worksheet cell, that cell must be formatted as text, not general or any numeric formatting. Alternatively, a leading apostrophe can be added to the return value before returning it to a cell.
In future versions I may need to have xlPrecision detect what client is
using it and restrict random clients' usage, requiring their developers to
license it. But I'll be sure to allow
Excel's VBA to use it without restriction. Any future restriction would apply only to other
random EXEs trying to use xlPrecision, not to Excel VBA.
2,147,483,648 SD Edition
A 2,147,483,648 SD Edition of xlPrecision is available for use in your programming code. Yes, that's over TWO BILLION significant digits. Of course, you can also use any other edition of xlPrecision in your programming code.
This edition was created at the request of a number theorist in Germany, who needed at least 110,000 significant digits, and possibly more, for his number theory project.
The 2,147,483,648 SD Edition has not been as thoroughly tested as the other editions. PrecisionCalc has tested only a few very simple scenarios of 40,000 significant digits. In addition, the number theorist who requested this edition tested it to his complete satisfaction, and found no bugs to report. If you encounter any problem with this edition, report the problem in detail and it will be fixed and the fixed version will be sent to you.
This edition is intended for use in your programming code, such as VBA. Use caution if using the 2,147,483,648 SD edition within an Excel worksheet, because Excel worksheets cannot accept more than 32,767 characters.
Why exactly 2,147,483,648 significant digits? Because xlPrecision numbers are stored and manipulated internally as text strings, and xlPrecision's programming environment does not permit text strings longer than 2^32 characters long. 2^32 (two to the thirty-second power) is 2,147,483,648. It may be possible to make an edition that is limited only by memory by using arrays of those text strings, but it would take some work to get the math procedures to work with those arrays.
| If using the
2,147,483,648 edition in Word VBA, note that Word VBA's
TypeText method is limited to 64k, which on
unicode versions of Word (such as Word 2003) is 32,767 characters.
If you exceed that, it starts over; for example, if you give it 32,769
characters, it returns only the first 2 characters (32,769 - 32,767 = 2). To work around that limitation, use Word VBA's InsertBefore method instead of TypeText. Or, if InsertBefore doesn't suit your needs, another approach would be to loop through the text 32,767 characters at a time, using Mid to get a 32,767-character chunk, and doing a TypeText on that chunk, each time through the loop. |
The 2,147,483,648 SD Edition is available as a Free Edition, a Express Edition, a Research Edition, and a Site License:
To get this to work on another machine, simply install the free edition from http://precisioncalc.com/DownloadFree.html, then follow the steps above.
When you restart Excel, if you get an error message saying that it can't find where xlPrecision is registered, follow these steps to manually register the 2,147,483,648 SD Free Edition DLL:
regsvr32 "C:\Program
Files\xlPrecision\xlPrecision.dll"
As easy as 3.1415926536.