|
-
Jul 3rd, 2006, 04:57 AM
#1
Thread Starter
Frenzied Member
seperating variable into mantissa and exponent
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)
-
Jul 5th, 2006, 03:55 PM
#2
Fanatic Member
Re: seperating variable into mantissa and exponent
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
-
Jul 5th, 2006, 04:54 PM
#3
Thread Starter
Frenzied Member
Re: seperating variable into mantissa and exponent
thanks for the reply
i guess
determines the position of E, correct?
-
Jul 5th, 2006, 06:59 PM
#4
Fanatic Member
Re: seperating variable into mantissa and exponent
 Originally Posted by vb_student
thanks for the reply
i guess
determines the position of E, correct?
It does indeed.
-
Jul 6th, 2006, 04:19 AM
#5
Thread Starter
Frenzied Member
Re: seperating variable into mantissa and exponent
thanks for the reply dude
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|