Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
b+ String Math Update
#20
https://qb64phoenix.com/forum/showthread.php?tid=787  -- I have.   Smile

The one important thing that I want to bring to people's attention is string math doesn't need to be one digit at a time.   

999 plus
999
------

Most folks who write string math will solve that one digit at a time.  9+9 =18 18... Write the 8, carry the 1...

999+
999
------
??8   (Carry 1)

Then they solve the next single character.  9 + 9 + 1...

999+
999
----- 
?98 (carry 1)

Only 1 digit at a time...   BUT!!   There's no reason for that!  Base 100 math follows the same rule set.  99 + 99 =198...  which is 98 (carry 1).   Base 1000 math is the same... and so on...

So why not read 17 digits at a time as an unsigned integer 64, and do all that in a single calculation??   It's much faster than trying to go a single character at a time.


Same with multiplication, but to a lesser degree.  I think you can multiply 8 or 9 digits by 8 or 9 digits and have no overflow.  It's not as efficient as addition, but it's still much better than just a single digit at once.
Reply


Messages In This Thread
b+ String Math Update - by bplus - 09-26-2022, 06:01 PM
RE: b+ String Math Update - by Pete - 09-26-2022, 06:27 PM
RE: b+ String Math Update - by bplus - 09-26-2022, 06:38 PM
RE: b+ String Math Update - by Pete - 09-26-2022, 06:53 PM
RE: b+ String Math Update - by vince - 09-29-2022, 03:16 AM
RE: b+ String Math Update - by bplus - 09-29-2022, 09:26 AM
RE: b+ String Math Update - by Pete - 09-29-2022, 07:59 PM
RE: b+ String Math Update - by bplus - 10-01-2022, 05:22 PM
RE: b+ String Math Update - by bplus - 10-01-2022, 05:30 PM
RE: b+ String Math Update - by Pete - 10-01-2022, 06:09 PM
RE: b+ String Math Update - by bplus - 10-01-2022, 06:45 PM
RE: b+ String Math Update - by bplus - 10-02-2022, 01:49 AM
RE: b+ String Math Update - by Kernelpanic - 04-03-2025, 04:14 PM
RE: b+ String Math Update - by Dragoncat - 04-02-2025, 06:29 AM
RE: b+ String Math Update - by bplus - 04-02-2025, 01:35 PM
RE: b+ String Math Update - by SMcNeill - 04-02-2025, 02:02 PM
RE: b+ String Math Update - by Dragoncat - 04-04-2025, 06:42 AM
RE: b+ String Math Update - by SMcNeill - 04-04-2025, 07:28 AM
RE: b+ String Math Update - by bplus - 04-02-2025, 02:26 PM
RE: b+ String Math Update - by SMcNeill - 04-02-2025, 03:11 PM
RE: b+ String Math Update - by Pete - 04-03-2025, 05:02 PM
RE: b+ String Math Update - by SMcNeill - 04-03-2025, 06:12 PM
RE: b+ String Math Update - by Pete - 04-03-2025, 06:18 PM
RE: b+ String Math Update - by SMcNeill - 04-03-2025, 07:24 PM
RE: b+ String Math Update - by Pete - 04-03-2025, 09:43 PM
RE: b+ String Math Update - by SMcNeill - 04-03-2025, 10:11 PM
RE: b+ String Math Update - by Pete - 04-03-2025, 11:49 PM
RE: b+ String Math Update - by bplus - 04-04-2025, 12:40 AM
RE: b+ String Math Update - by Dragoncat - 04-04-2025, 04:53 AM
RE: b+ String Math Update - by Dragoncat - 04-11-2025, 07:02 AM
RE: b+ String Math Update - by Dragoncat - 04-11-2025, 07:27 AM
RE: b+ String Math Update - by bplus - 04-11-2025, 11:56 AM



Users browsing this thread: 2 Guest(s)