Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculations Needing Big Integers....
#11
If you have to compute factorial or Fibonnaci or something like that you're out of luck strictly within QB64's world, because the values get very large very quickly...

But if you have to do something up to 18 digits of precision, and even if you have to cheat a bit with the decimal point, then _INTEGER64 is good enough. Granted that in Microsoft BASIC PDS v7.1 the CURRENCY type was a LONG internally, but a special case was made whenever it was printed. Something like that could be arranged for _INTEGER64 to get a rational "precise" 6-digit mantissa or something like that.

I remembered a while ago before 64-bit OS became all the rage, that somebody invented a "longlongs" structure in C to have 64-bit integers. Maybe that old code could be brought back so we could have 128-bit integers LOL.
Reply
#12
(07-09-2023, 06:46 PM)mnrvovrfc Wrote: If you have to compute factorial or Fibonnaci or something like that you're out of luck strictly within QB64's world, because the values get very large very quickly...

But I just did it to 10,000 Fibonacci in the QB64 world, here:  https://qb64phoenix.com/forum/showthread...0#pid17680
Reply
#13
(07-09-2023, 06:46 PM)mnrvovrfc Wrote: If you have to compute factorial or Fibonnaci or something like that you're out of luck strictly within QB64's world, because the values get very large very quickly...

But if you have to do something up to 18 digits of precision, and even if you have to cheat a bit with the decimal point, then _INTEGER64 is good enough. Granted that in Microsoft BASIC PDS v7.1 the CURRENCY type was a LONG internally, but a special case was made whenever it was printed. Something like that could be arranged for _INTEGER64 to get a rational "precise" 6-digit mantissa or something like that.

I remembered a while ago before 64-bit OS became all the rage, that somebody invented a "longlongs" structure in C to have 64-bit integers. Maybe that old code could be brought back so we could have 128-bit integers LOL.
Thanks for this note...totally agree.  For Big Ints you can use Python or Haskell (ugh!) and others that have only memory limit on digits.

Here is the output of a small C++ program I wrote to run on my Windows 11 PC x64 that provides the bits/bytes of each type.  This is important since int and some of the floats are OS/Chipset dependent in some cases.  Hence the _t types too.....

-----------------------------------------------------------
  Number types in Cpp w/size on this PC in bits and bytes
-----------------------------------------------------------
               char: | bits 1  | bytes: 8   |
        signed char: | bits 1  | bytes: 8   |
      unsigned char: | bits 1  | bytes: 8   |
              _Bool: | bits 1  | bytes: 8   |
          short int: | bits 2  | bytes: 16  |
                int: | bits 4  | bytes: 32  |
            int32_t: | bits 4  | bytes: 32  |
           long int: | bits 4  | bytes: 32  |
      long long int: | bits 8  | bytes: 64  |
              off_t: | bits 4  | bytes: 32  |
             size_t: | bits 8  | bytes: 64  |
          ptrdiff_t: | bits 8  | bytes: 64  |
          uintptr_t: | bits 8  | bytes: 64  |
              void*: | bits 8  | bytes: 64  |
              float: | bits 4  | bytes: 32  |
             double: | bits 8  | bytes: 32  |
        long double: | bits 16 | bytes: 128 |
-----------------------------------------------------------
Reply




Users browsing this thread: 2 Guest(s)