Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
need a Scientific Notation to real number converter
#10
(10-12-2023, 09:32 AM)Jack Wrote: Thanks, will try it.

R1



or if you want the result in a string
Code: (Select All)

Declare Library
    Function snprintf& (Dest As String, Byval l As Long, frmt As String, Byval x As Double)
End Declare


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, 5, "f")
    A$ = Mid$(A$, 1, 6)
    P = P + Val(A$)

    Print A$
Next

P = (P / 9)
A$ = StrNum$(P, 5, "f")
A$ = Mid$(A$, 1, 6)
Print A$ + " <- averaged"
Color 10
Print "Press any key"
Sleep

Function StrNum$ (x As Double, places As Integer, format As String)
    Dim As String s
    Dim As String frmt
    Dim As Long l, ex, sign
    sign = Sgn(x)
    If sign < 0 Then x = -x
    s = Spc(64)
    frmt = "%." + _Trim$(Str$(places)) + format + Chr$(0)
    l = snprintf(s, Len(s), frmt, x)
    s = _Trim$(s)
    If InStr(s, ".") > 0 And Left$(s, 1) = "0" Then s = Mid$(s, 2)
    If sign < 0 Then s = "-" + s Else s = " " + s
    ex = InStr(s, "e")
    If ex > 0 Then Mid$(s, ex, 1) = "D"
    StrNum$ = s
End Function
Reply


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



Users browsing this thread: 3 Guest(s)