Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need a Scientific Notation to real number converter
#1
Hi all
Need help with a Scientific Notation to real number converter.   Below is a mockup for testing the Function but if I do the
calculations by hand the outputs don't match.  

Thanks in advance

R1

Code: (Select All)

FOR L1 = 1 TO 9
    IF L1 = 1 THEN A = 75 / 130
    IF L1 = 2 THEN A =  1 / 103
    IF L1 = 3 THEN A =  7 / 27
    IF L1 = 4 THEN A = 11 / 42
    IF L1 = 5 THEN A = 15 / 63
    IF L1 = 6 THEN A = 35 / 118
    IF L1 = 7 THEN A = 60 / 142
    IF L1 = 8 THEN A = 47 / 125
    IF L1 = 9 THEN A = 93 / 148

    A=A^2
    A$ = StrNum$(A)
    A$=MID$(A$,1,6)
    P=P + VAL(A$)

    PRINT A$
NEXT

P = (P/9)
A$ = STRNUM$(P)
A$=MID$(A$,1,6)
PRINT A$ + " <- averaged"
color 10
print "Press any key"
SLEEP
SYSTEM

FUNCTION StrNum$ (n)
    value$ = UCASE$(LTRIM$(STR$(n)))
    XPOS1 = INSTR(value$, "D") + INSTR(value$, "E")
    IF XPOS1 THEN
        expo = VAL(MID$(value$, XPOS1 + 1))
        IF VAL(value$) < 0 THEN
            sign$ = "-": value$ = MID$(value$, 2, XPOS1 - 2)
        ELSE value$ = MID$(value$, 1, XPOS1 - 1)
        END IF
        dot = INSTR(value$, "."): L = LEN(value$)
        IF expo > 0 THEN ADD$ = StrNum$(expo - (L - dot), "0")
        IF expo < 0 THEN min$ = StrNum$(ABS(expo) - (dot - 1), "0"): DP$ = "."
        FOR N = 1 TO L
            IF MID$(value$, N, 1) <> "." THEN num$ = num$ + MID$(value$, N, 1)
        NEXT
    ELSE StrNum$ = value$: EXIT FUNCTION
    END IF
    StrNum$ = sign$ + DP$ + min$ + num$ + ADD$
END FUNCTION
Reply


Messages In This Thread
need a Scientific Notation to real number converter - by random1 - 10-09-2023, 06:15 AM



Users browsing this thread: 4 Guest(s)