CD \libsf\source\xbase\bignum\ MODIFY PROJECT project\bignum.pjx DO bp DO go *MODIFY FORM frmTest.scx *MODIFY CLASS bignum OF bignum.vcxBasically you can drop the bignum class label object onto a form, and name it "bn". Or create a singleton called "bn". Then, to allocate a big number, use this VFP code:
lnId1 = thisForm.bn.new() && By default it uses 256-bit precision (you can change it on a class property) lnId2 = thisForm.bn.new(0, 512) && An example using 512-bit precision by single instance override, setting initial value to 0 lnId3 = thisForm.bn.new(3, 1024, .t.) && Use 1024-bit precision, and store 1024 as the new default, setting initial value to 3 * If a singleton, use: bn = CREATEOBJECT("bignum") lnId1 = bn.new() * In general, if you take the number of significant digits you want in base 10, and multiply by 3.3333333, and * round up to the nearest 64 bits, that's how big you need your value to be. * Using this bignum class will allow access to numbers that are literally megabytes long. * You could find the next prime number. :-)This returns an ID which lets you use it in later computations. To set a value:
thisForm.bn.set(lnId, "1234.56") lcValue = thisForm.bn.to_text(lnId) ? lcValueTo do calculations, do things like this:
thisForm.bn.mul(lnId1, lnId2) && Multiply the lnId1 bignum by the lnId2 bignum and store the result in lnId1 thisForm.bn.div(lnId1, lnId2) && Divide the lnId1 bignum by the lnId2 bignum and store the result in lnId1 ? thisForm.bn.to_text(lnId1) && Show the value of lnId1 in text form * Or if using a singleton bn.mul(lnId1, lnId2) && Multiply the lnId1 bignum by the lnId2 bignum and store the result in lnId1 bn.div(lnId1, lnId2) && Divide the lnId1 bignum by the lnId2 bignum and store the result in lnId1 ? bn.to_text(lnId1) && Show the value of lnId1 in text form * et ceteraThe only issue I'm aware of is the number format. I'll get that sorted out at some point soon. If someone wants to write the algorithm to convert the current format to a non-scientific notation format, please do so and submit it and I'll update the project.