Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Perpetual string math calculator.
#9
(08-11-2022, 08:49 PM)Kernelpanic Wrote:
Quote:That's why I coded my string math routine. You simply cannot "count" on binary computer math. (Please enjoy the pun.)


I enjoy it Rolleyes , but QuickBasic 4.5 could it - sure. In any case, it would be for . . . 99%(?) of all cases ok.

34.545 must not become 34.54. I had to do financial math once and there would be something like this - probably a case for lawyers because it turns out to be a few thousand dollars more on a loan payment, a mortgage, for example.

PS: It depends on where the error occurs. In the worst case, it really runs into the thousands and more, depending on the amount of the loan. That is not a trifle.

What you are referring to is called banker's rounding. Simply put, it is an algorithm that rounds .5 up or down depending on the number. so after many rounds there is a better chance the banker's rounded figures would add up to the actual total amount if all of the transactions were calculated at one time on a precision calculator.

Here is an online example of how the algorithm would apply:
  • 0.5 rounds down to 0. Why? Because 0 is the nearest even integer.
  • 1.5 rounds up to 2. Why? Because 2 is the nearest even integer. 
  • 73.5 rounds up to 74. Why? Because 74 is the nearest even integer. 
  • 74.5 rounds down to 74. Why? Because 74 is the nearest even integer. 
  • 75.5 rounds up to 76. Why? Because 76 is the nearest even integer. 
  • 76.5 rounds down to 76. Why? Because 76 is the nearest even integer. 

I may, at some point, code this algorithm for my string math routine but for now, I'm fixated on the rounding used to display the last digit in a calculator display.

Thanks,

Pete
Reply


Messages In This Thread
Perpetual string math calculator. - by Pete - 08-10-2022, 05:11 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 03:24 AM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 12:39 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 08:29 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 10:08 PM
RE: Perpetual string math calculator. - by bplus - 08-11-2022, 10:07 PM
RE: Perpetual string math calculator. - by Jack - 08-11-2022, 10:35 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 11:35 PM
RE: Perpetual string math calculator. - by Jack - 08-11-2022, 11:42 PM
RE: Perpetual string math calculator. - by Pete - 08-11-2022, 11:51 PM
RE: Perpetual string math calculator. - by Pete - 08-12-2022, 01:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Word Processor Using Single String Pete 3 223 02-28-2026, 12:07 AM
Last Post: Pete
  new approach to base conversion system and math library Dragoncat 2 577 07-16-2025, 10:19 PM
Last Post: Dragoncat
  b+ String Math Update bplus 31 5,194 04-11-2025, 11:56 AM
Last Post: bplus
  I'm adding SQR to my new faster string math routines... Pete 17 3,319 04-01-2025, 04:56 PM
Last Post: Pete
  Font from a string pattern - help needed grymmjack 22 4,989 08-27-2023, 07:26 PM
Last Post: grymmjack

Forum Jump:


Users browsing this thread: 1 Guest(s)