You're welcome, We all have our unique talents, and what I can't see others do and vise versa. That's why we have these forums. To share ideas and help each other if we can.
Like some of the stuff that Dutchman, Henko and Ricardo and I have been talking about input fields has helped me greatly as I am writing a parser for both JSON and XML files. I was a consultant to Verizon-TSI and GSM (those in Europe should be very familiar with who GSM is), as I am the reason they were able back then to use their cell phones to purchase soda and beer at vending machines with their (at the time) GSM phones, among other items like groceries and movie tickets.
I helped them perfect their TAP3 file processing. It started out as XML and my senior analyst and I devised a way to encode it into a binary stream and decode it on our end for processing. It was a great project. We wrote most of it in Assembler. Back then it cost a ton to transmit data and even use the Internet, so time online was important and using binary with compression shortened file sizes.
So let me know if you need help with pre-converting to binary strings. Lua has the same limitation of 2^53 (has to do with 64-bit floating point) and Lua as with SB are both written in C/C++, which if I can recall the thread we had this discussion before, it is a hardware math processor limitation. Most languages layoff their math to a math co-processor because it is faster than writing all that assembler code or C/C++ code to do formulas.
I am still looking for a way to do large number math. Towards the end of last year I helped a scientist with her peer-review paper on leap seconds for the ITU, and then she wrote a book on KOBO. I proofed all the math and science and got a nice acknowledgement in her book. This is just some of the stuff I do in Cosmology/Physics and I hate doing Trig and Calc longhand.
And I was unpleasantly surprised when helping another astronomer with a paper on temperatures of black holes. It was the first time I had used SmartBASIC for something this important and the numbers were all wrong.
The code is below, but this is to show you why it is important to have a string format that preserves the precision of all integers and decimals.
Our manual is still wrong. We are able to do 2^53, not 2^52. And below I also threw in what happens when you decide to show all 30 integers. For example, the mass of the Earth is about 2*10^30. That's 2 with 30 zeroes. Below is what happens in SmartBASIC:
The maximum absolute value 2^52 = 4,503,599,627,370,496
Add 4503599627370496 to itself = 9,007,199,254,740,992
The maximum absolute value 2^53 = 9,007,199,254,740,992
The mass of the Sun, 2*10^30 = 2000000000000000039769249677312
As an exponent, the Sun's Mass. = 2E+30
Look at all those non-zero numbers inserted. For most all uses, 9,007,199,254,740,992 is plenty big enough. But when I coded my formulas and even when it did the math in exponential form, because of the 7-digit mantissa, it looked like the results were right, but at the end they were not because of those non-zeroes were inserted even in exponential calculations.
So if you need a hand with creating a similar string format that Lua and some others have to preserve every integer no matter how long the number is, let me know. I am in need of a solution (for personal work) and I have been searching and learning new languages because of it, which is not a bad thing.
When I started my career in 1975, I thought assembler and machine code was all I would need. Once I learned COBOL, PL/1, PL/C (Caltech's version based on PL/1), RPG and many others, it allowed me to take the best of each and when needed I was able to write my own functions, preprocessors/precompiler code, inline preprocessor (such as allowing SAS code to compile in a PL/1 program) and many other things needed by others.
If you need help, let me know, and also I bet many here would also help as they too would like to do precision long integer math.
George.
PS: The reference manual needs to read 2^53, not 52.
Code: Select all
X=2^52
Y=2*10^30
Z=2^53
W=4503599627370496+4503599627370496
F16$="#,###,###,###,###,###"
F20$="##,###,###,###,###,###,###"
F30$="##############################"
X$=STR$(X,F16$)
Y$=STR$(Y,F30$)
Z$=STR$(Z,F16$)
W$=STR$(W,F16$)
PRINT "The maximum absolute value 2^52 = "&X$
PRINT "Add 4503599627370496 to itself = "&W$
PRINT "The maximum absolute value 2^53 = "&Z$
PRINT "The mass of the Sun, 2*10^30 = "&Y$
PRINT "As an exponent, the Sun's Mass. = "&Y
STOP
sarossell wrote: ↑Mon Jan 16, 2017 4:48 am
Thanks very much for the encouragement. I figure that an incoming number need not be defined by base since it's digits will self-determine the upper range. I've also been thinking that in order to avoid smart BASIC's 53 bit base-10 number limitation, I may have to pre-convert to binary in an arbitrarily long string variable instead of decimal with its limitations.
I set this aside for a bit in order to focus on the basics I was familiar with in other versions of BASIC. For example, I've been trying to figure out how to print inverse and flashing text within a sentence using defined functions like INVERSE() and FLASH(). Yet again though, I have no idea how. But it will be fun to figure it out.
Fear not, I don't give up. In fact, I've been working on a particular encryption/compression problem since 1998.