Skip to Content

.. very simple issue.. very urgent.

Hi SDN,

We are finding out Longitude and Latitude for getting some output based on the address of customer..

I see there is use of Trignometric functions here..

I Just want to find out TAN 45 degreese value in ABAP..

When I calculate <b>TAN ( 45 )</b> in ABAP and its giving me some wriong value instead of 1. I think its considering 45 as a number not the degree..

I want to calculate TAN 45 degree value.. How to do that in ABAP..

Point sure..

regards,

nazeer

Message was edited by:

N a z e e r

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

5 Answers

  • Best Answer
    author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 06:38 AM

    hai nazeer,

    go through this code , which clarifies your doubt.

    DATA : p_data TYPE i.

    DATA: pi TYPE p DECIMALS 2,

    degree TYPE f VALUE 45,

    radians TYPE f.

    pi = 22 / 7.

    degree = 45.

    radians = ( degree * pi ) / 180.

    p_data = tan( radians ).

    WRITE : p_data.

    <b>reward points if helpfull.</b>

    with regards,

    radhika kolluru.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 05:34 AM

    Hi Nazeer ,

    What is the value you are getting .

    Is it 1.61977519.

    As posted in the post by Mukesh , you need to convert degrees to

    radians , this can be done using the forumla

    Radians = ( Degree * Pi ) / 180

    Please see the link

    Linkhttp://www.teacherschoice.com.au/Maths_Library/Angles/Angles.htm">Link>

    Regards

    Arun

    Message was edited by:

    Arun R

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 05:36 AM

    Hi nazeer,

    You will have to change your value to RADIAN first for 45 degree the value in RADIAN is 0.785 (785 / 1000).

    Check this code.

    data : p_data type i.

    p_data = TAN( 785 / 1000 ).

    write : p_data.

    It is giving result 1 as expected for TAN 45 degree.

    If you have still some doubt reply this thread otherwise reward point and please close the thread.

    Regards,

    Mukesh Kumar

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 05:39 AM

    Hi Nazeer,

    The value of Tan(45) is beng wrongly calculated by ABAP because internally the data type for all the Trignometric functions are represented as Floating point numbers.

    Please refer to this:

    The results of the following functions have the data type f:

    &#61599; Trigonometric functions: cos, acos, sin, asin, tan, atan

    &#61599; Hyperbolic functions: tanh, sinh, cosh

    &#61599; Exponential functions (base e): exp

    &#61599; Natural logarithms (base e): log

    &#61599; Logarithms (base 10): log10

    &#61599; Square root: sqrt

    In case you have any further clarifications,do let me know.

    Regards,

    Puneet Jhari.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Posted on Sep 28, 2007 at 06:13 AM

    TAN in ABAP works on Radians and not degrees, so if u hav degrees you need to convert it into radians, see the e.g. below:

    data:

    degrees type f value 45,

    radians type f.

    data:

    show type p decimals 2.

    radians = '0.0174532925' * degrees.

    show = tan( radians ).

    write show.

    Reward points if useful, get back in case of query...

    Cheers!!!

    Add comment
    10|10000 characters needed characters exceeded