06-14-2022, 06:10 AM
Cobol was the quintessential language for numbers.
I use string math, a rather lengthy program I coded for numbers. I also used to use a rounding method for smaller needs, and with _INTEGER64 I now use this...
Press a key to view 5-screens of results. After that, it loops on its own to 1-million dollars or until you click the "x" to close the program.
Pete
I use string math, a rather lengthy program I coded for numbers. I also used to use a rounding method for smaller needs, and with _INTEGER64 I now use this...
Code: (Select All)
WIDTH 50, 42
_SCREENMOVE 0, 0
_DELAY .2
add$ = ".00"
a! = .01
FOR i&& = 1 TO 100000000 ' 1-million dollar count.
a1&& = a! * 100
add&& = add&& + a1&&
add$ = LTRIM$(STR$(add&&))
IF LEN(add$) < 3 THEN
add$ = MID$(".00", 1, 3 - LEN(add$)) + add$
ELSE
add$ = MID$(add$, 1, LEN(add$) - 2) + "." + RIGHT$(add$, 2)
END IF
x = LEN(add$): IF LEFT$(add$, 1) = "-" THEN x = x - 1
j = 4
DO UNTIL j / 4 >= (x - 3) / 3
add$ = MID$(add$, 1, LEN(add$) - 3 + 1 - j) + "," + MID$(add$, LEN(add$) - 3 + 1 - j + 1)
j = j + 4
LOOP
PRINT i&&, add&&;
printx add$
a$ = ""
FOR j = 1 TO LEN(add$)
IF MID$(add$, j, 1) <> "," AND MID$(add$, j, 1) <> "." THEN a$ = a$ + MID$(add$, j, 1)
NEXT
IF i&& <> VAL(a$) THEN PRINT a$, VAL(a$): BEEP: SLEEP
IF i&& < 200 AND i&& MOD 40 = 0 THEN SLEEP ' View a few screens.
NEXT
SUB printx (x$)
LOCATE , _WIDTH - 2 - LEN(x$)
PRINT x$
END SUB
Press a key to view 5-screens of results. After that, it loops on its own to 1-million dollars or until you click the "x" to close the program.
Pete
If eggs are brain food, Biden takes his scrambled.