Thread
:
Setting an absolute value in Java
View Single Post
#
3
27-09-2014, 01:36
Caleb Sykes
Registered User
FRC #4536 (MinuteBots)
Team Role: Mentor
Join Date: Feb 2011
Rookie Year: 2009
Location: St. Paul, Minnesota
Posts: 1,048
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; }
Caleb Sykes
View Public Profile
Find all posts by Caleb Sykes
Find CD-Media Photos by Caleb Sykes
Find CD-Media Papers by Caleb Sykes