Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Roots and powers playing nicely together...
#2
Okay, so with mixed numbers you have to line up the number for root division. Groups per root both left and right of the decimal point. This little routine helps visualize the process...

Code: (Select All)
WIDTH 140, 25
DO
    INPUT "Root: "; r
    ' How to line up root equations.
    ' 23.0347 root = 3 instr() = 3 dp (3 - 1) = 2 digits = (7 - 1) = 6
    ' 23|034|7 ' root 3 example.
    ' .0024768
    ' |002|467|8 ' root 3 example.
    ' 3509875.45
    ' 3|509|875|45 ' root 3 example.
    REDIM a1$(3)
    a1$(1) = "23.0347"
    a1$(2) = ".0024768"
    a1$(3) = "3509875.45"

    FOR h = 1 TO 3
        PRINT a1$(h),
        i = INSTR(a1$(h), ".") - 1 ' digits before decimal.
        j = LEN(a1$(h)) - 1 ' Number of digits.
        a$ = MID$(a1$(h), 1, INSTR(a1$(h), ".") - 1) + MID$(a1$(h), INSTR(a1$(h), ".") + 1)
        PRINT "Digits before decimal ="; i; "  Number of digits ="; j; "Number: "; a1$(h); SPACE$(14 - LEN(a1$(h)));
        FOR k = 1 TO j
            IF (k - (i - r + 1)) MOD r = 0 THEN PRINT "|";
            PRINT MID$(a$, k, 1);
        NEXT
        PRINT
    NEXT h
    PRINT
    CLEAR
LOOP

Pete
Reply


Messages In This Thread
RE: Roots and powers playing nicely together... - by Pete - 09-28-2022, 05:17 PM



Users browsing this thread: 15 Guest(s)