# .. 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

10|10000 characters needed characters exceeded

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,

pi = 22 / 7.

degree = 45.

radians = ( degree * pi ) / 180.

WRITE : p_data.

with regards,

10|10000 characters needed characters exceeded
• 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

Regards

Arun

Message was edited by:

Arun R

10|10000 characters needed characters exceeded
• 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.

Regards,

Mukesh Kumar

10|10000 characters needed characters exceeded
• 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.

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.

10|10000 characters needed characters exceeded
• 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,

data:

show type p decimals 2.