View Single Post
  #22   Spotlight this post!  
Unread 01-02-2013, 19:06
omalleyj omalleyj is offline
Registered User
AKA: Jim O'Malley
FRC #1279 (Cold Fusion)
Team Role: Mentor
 
Join Date: Jan 2008
Rookie Year: 2008
Location: New Jersey
Posts: 132
omalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to beholdomalleyj is a splendid one to behold
Re: remainder function

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.

Last edited by omalleyj : 01-02-2013 at 19:16. Reason: still can't spell after all these years
Reply With Quote