- Home
·
- Math/Dates
·
- will convert a double to an engineering format (i.e. p, n, u, m, K, M, G, T) to a given number of s
will convert a double to an engineering format (i.e. p, n, u, m, K, M, G, T) to a given number of s
will convert a double to an engineering format (i.e. p, n, u, m, K, M, G, T) to a given number of significant figures
Rate will convert a double to an engineering format (i.e. p, n, u, m, K, M, G, T) to a given number of s
(1(1 Vote))
Dim tmpResult As String
Dim unit As String
Dim n As Integer
Dim value As Double
tmpResult = CStr(Abs(dblNumber))
If intSF > Len(tmpResult) Then intSF = Len(tmpResult)
n = 0
value = dblNumber
If value >= 10 Then
Do Until value < 10
n = n + 1
value = value / 10
Loop
Else
Do Until value >= 1
n = n - 1
value = value * 10
Loop
End If
If n >= 15 Then
MsgBox "Number formatting failed", vbExclamation
ElseIf n >= 12 Then
unit = unit & "T"
n = n - 12
ElseIf n >= 9 Then
unit = unit & "G"
n = n - 9
ElseIf n >= 6 Then
unit = unit & "M"
n = n - 6
ElseIf n >= 3 Then
unit = unit & "K"
n = n - 3
ElseIf n >= 0 Then
unit = unit & ""
ElseIf n >= -3 Then
unit = unit & "m"
n = n + 3
ElseIf n >= -6 Then
unit = unit & "u"
n = n + 6
ElseIf n >= -9 Then
unit = unit & "n"
n = n + 9
ElseIf n >= -12 Then
unit = unit & "p"
n = n + 12
ElseIf n >= -15 Then
MsgBox "Number formatting failed", vbExclamation
End If
tmpResult = CStr(Abs(value))
tmpResult = Left$(tmpResult, intSF)
value = CDbl(tmpResult)
Do Until n = 0
n = n - 1
value = value * 10
Loop
tmpResult = CStr(Abs(value))
tmpResult = Left$(tmpResult, intSF)
HumanReadableWithSF = tmpResult & unit
End Function
will convert a double to an engineering format (i.e. p, n, u, m, K, M, G, T) to a given number of s Comments
No comments yet — be the first to post one!
Post a Comment