View Single Post
  #3   Spotlight this post!  
Unread 27-09-2014, 01:36
Caleb Sykes's Avatar
Caleb Sykes Caleb Sykes is offline
Registered User
FRC #4536 (MinuteBots)
Team Role: Mentor
 
Join Date: Feb 2011
Rookie Year: 2009
Location: St. Paul, Minnesota
Posts: 1,048
Caleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond reputeCaleb Sykes has a reputation beyond repute
Re: Setting an absolute value in Java

^Math.abs() is the way to go.

Just as a thought experiment though, you should be able to make your own abs() function in just a few lines of code. Something like:
Code:
double abs(double val) 
{
     if(val < 0)
          return -val;
     else
          return val;
}
Reply With Quote