Hello
can you guys tell me how to seperate a number into its mantissa and exponents parts
e.g. u = 1.3e+123
is there any way i can do something like
mantissa = u.mantissa
exponent = u.exponent (where u is the variable)
Printable View
Hello
can you guys tell me how to seperate a number into its mantissa and exponents parts
e.g. u = 1.3e+123
is there any way i can do something like
mantissa = u.mantissa
exponent = u.exponent (where u is the variable)
The task should be straightforward string parsing:
VB Code:
Option Explicit Private Type NumMantExp Exp As Integer Mant As Double End Type Sub MantExp() Dim dX As Double Dim sX As String Dim iX As Integer Dim num1 As NumMantExp dX = -0.00234556234586 * 1E-56 sX = Format(dX, "#.##############################E+####") iX = InStr(sX, "E") num1.Exp = Val(Mid(sX, iX + 1, Len(sX))) num1.Mant = Val(Left(sX, iX - 1)) Debug.Print "mantissa = " & num1.Mant Debug.Print "exponent = " & num1.Exp End Sub
thanks for the reply
i guess
VB Code:
iX = InStr(sX, "E")
determines the position of E, correct?
It does indeed.Quote:
Originally Posted by vb_student
thanks for the reply dude