For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > February 2006 > Exponential calculation headache









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Exponential calculation headache
JP Bless

2006-02-26, 7:55 am

I need to calculate the exponential value of a number...
That is basically the number raised to power 10
X ^ 10
so debug.Print 10 ^ 10 gives the right answer 100000000000
But when I do same using VB intrinsic Exp function I get the wrong answer
Debug.Print Exp(10) gives 22026.4657948067

What I am doing wrong? What is VB's own Exponential formular


Norm Cook

2006-02-26, 6:55 pm


From the help,
Exp() Returns a double specifying e (the base of natural logarithms) raised
to a power.
Here's a function that computes 10^10 using exp()

Function Exponent(ByVal Base As Long, ByVal X As Double) As Double
Exponent = Exp(X * Log(Base))
End Function

Private Sub Form_Load()
debug.print 10^10
Debug.Print Exponent(10, 10)
End Sub

"JP Bless" <jp3BlessNoSpam@hotmail.com> wrote in message
news:udRaWptOGHA.2036@TK2MSFTNGP14.phx.gbl...
> I need to calculate the exponential value of a number...
> That is basically the number raised to power 10
> X ^ 10
> so debug.Print 10 ^ 10 gives the right answer 100000000000
> But when I do same using VB intrinsic Exp function I get the wrong answer
> Debug.Print Exp(10) gives 22026.4657948067
>
> What I am doing wrong? What is VB's own Exponential formular
>
>



JP Bless

2006-02-26, 6:55 pm

Works great... thanks Norm

"Norm Cook" <normcookNOSPAM@cableone.net> wrote in message
news:1203d06q4vjau6f@corp.supernews.com...
>
> From the help,
> Exp() Returns a double specifying e (the base of natural logarithms)

raised
> to a power.
> Here's a function that computes 10^10 using exp()
>
> Function Exponent(ByVal Base As Long, ByVal X As Double) As Double
> Exponent = Exp(X * Log(Base))
> End Function
>
> Private Sub Form_Load()
> debug.print 10^10
> Debug.Print Exponent(10, 10)
> End Sub
>
> "JP Bless" <jp3BlessNoSpam@hotmail.com> wrote in message
> news:udRaWptOGHA.2036@TK2MSFTNGP14.phx.gbl...
answer[color=darkred]
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com