Omiye Jay Jay - 1 year ago 85

Java Question

I would like to convert the

`Math.sin(x)`

`x`

`x`

I have used the normal method and java built in method of conversion between degrees and radians, but any argument I pass to the

`Math.sin()`

I want the output of a sin Input to be given as if the input is treated in degrees not radians like the

`Math.sin()`

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

Java's `Math`

library gives you methods to convert between degrees and radians: toRadians and toDegrees:

```
public class examples
{
public static void main(String[] args)
{
System.out.println( Math.toRadians( 180 ) ) ;
System.out.println( Math.toDegrees( Math.PI ) ) ;
}
}
```

If your input is in degrees, you need to convert the number going in to `sin`

to radians:

```
double angle = 90 ;
double result = Math.sin( Math.toRadians( angle ) ) ;
System.out.println( result ) ;
```

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**