In a Java SE project this
Code:
double result;
double x[] = {179, 180, 181, 359, 721, -1, -179, -180, -359, -361, -721};
for (int i = 0; i < x.length; i++){
result = Math.IEEEremainder(x[i],360.0);
System.out.println("x: " + x[i] + " rem y: 360 result: " + result);
}
yields this:
Code:
x: 179.0 rem y: 360 result: 179.0
x: 180.0 rem y: 360 result: 180.0
x: 181.0 rem y: 360 result: -179.0
x: 359.0 rem y: 360 result: -1.0
x: 721.0 rem y: 360 result: 1.0
x: -1.0 rem y: 360 result: -1.0
x: -179.0 rem y: 360 result: -179.0
x: -180.0 rem y: 360 result: -180.0
x: -359.0 rem y: 360 result: 1.0
x: -361.0 rem y: 360 result: -1.0
x: -721.0 rem y: 360 result: -1.0
which I believe is what you are looking for.
However I cannot use IEEERemainder() in an FRC project they have compiled the jar without it apparently.