Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

.. very simple issue.. very urgent.

former_member588853
Active Contributor
0 Kudos

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

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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.

5 REPLIES 5

Former Member
0 Kudos

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

<a href="http://www.teacherschoice.com.au/Maths_Library/Angles/Angles.htm">Link</a>

Regards

Arun

Message was edited by:

Arun R

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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!!!

Former Member
0 Kudos

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.