Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

convert exponential # to dbl

Status
Not open for further replies.

slybitz

Technical User
Mar 25, 2005
113
US
I have a calculation that is taking one number minus another number. The result (a variable I named "strCents") comes out as an exponential number rather than just a type of double. How can I convert this exponential value to a data type of double?

Example:
The value being calculated is 6.55000000000001E-02. I want to convert this value to .0655. This value is dynamic so it won't always be in the format of #.####E-## except for the ending value of the exponential number which will always be in the format of E-##.

Is this possible? Thanks!
 





Hi,

Secientific notation or some decimal notation is merely a FORMAT. The underlying NUMBER is a NUMBER..

Check out the NumberFormat property of the range object.

Skip,

[glasses] [red][/red]
[tongue]
 
slybitz said:
The result (a variable I named "strCents")

Is [tt]strCents[/tt] declared as a String or Double?

CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
It is declared as a string. Sorry I should have mentioned that. Thanks.
 
You may always play with the conversion functions like CDbl, CSng, CDec, ...

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
slybitz,
Assign the result to a double data type variable instead of a string. Then if you need the number in a specific format in a later step you can use [tt]Format$()[/tt] to coherce the number to the exact string format you need?

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Thanks for all of your help. I think I figured it out by taking the E-## part of the string and finding out where the decimal should go from that bit of info. Kind of complicated and funky to explain but it works.
 
Seems you are this sort of guy prefering the hard way, don't you ;-)
 
haha yeah well for some reaosn it wouldn't work by just converting the number. It will convert the number if the number were something like 6.5500000000000E-02 but if it were like 6.55000000000001E-02 with the added 1 it won't convert. I think it's a matter of how many digits there are after the decimal in which dictates the number defaulting to a exponential number or not.
 
What about this ?
MsgBox Format(6.55000000000001E-02, "0.0000000000000000")

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top