CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2002
    Location
    NC
    Posts
    125

    radians vs degrees(Resolved)

    Im trying to get the Log() of the number in VB. After messing with the formula for a while I realized I could not get the same answer on the simplist number as I would with the M.S. calculator. It was then I figured out that by default, the Deg. is checked in calculator scientific view, when I checked Radians and ran my numbers I got the same answer as VB was giving me. What that tells me is that VB uses the Radians to give the Log() of a number. What I want to do is get the Degrees answer in VB, (the same answer I get in calculator with Degrees.)
    Can anyone help?

    Here is the code if it helps
    Code:
    Dim gain1 As Single
    Dim gain2 As Single
    Dim gain3 As Single
    gain1 = 1.0666 * 1.0666 * 12 * .2126
    gain2 = Log(gain1) ' Log of gain1 should be .4627 but its not in VB
    gain3 = 11.8 + (10 * gain2)
    t_gain.Text = gain3 ' this number should be 16.42 in VB but VB shows something very different
    Thanks
    Last edited by dedub; October 6th, 2006 at 09:52 PM.
    R.L.T.W. A+, NET+, CCNA

    doin' my best

  2. #2
    Join Date
    Jul 2005
    Posts
    1,083

    Re: radians vs degrees

    It could be helpful if you google 'radians to degrees conversion'
    1 radians = 57.2957795 degrees

  3. #3
    Join Date
    Nov 2002
    Location
    California
    Posts
    4,556

    Re: radians vs degrees

    Quote Originally Posted by dedub
    ... What that tells me is that VB uses the Radians to give the Log() of a number. What I want to do is get the Degrees answer in VB, (the same answer I get in calculator with Degrees.)
    Radians vs. degrees is an issue only in the trigonometric functions like sin() cos() and tan().

    It is not a meaningful question in the context of the Log() function, which is a logarithmic function.

    You are probably seeing a difference because of a difference in the base of the Log() function.

    In MS Calculator, Log returns the logarithm base 10.

    In VB, the Log() function by default returns the logarithm base "e" (e=2.71828...), which is usually called the "natural log". On the MS Calculator, you can get this same value with the Ln function.

    You need to use the overload of the VB Log() function, which takes two arguments where the second argument is the desired base. See http://msdn2.microsoft.com/en-us/library/hd50b6h5.aspx

    Mike

  4. #4
    Join Date
    Dec 2002
    Location
    NC
    Posts
    125

    Re: radians vs degrees

    Mike, thanks for the explanation, I got the formula to work
    R.L.T.W. A+, NET+, CCNA

    doin' my best

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured