Go to Post I personally think that everybody on the team is important. No matter what, every single student, mentor, teacher put their effort all year long to get the team going. So in my opinion, Credit goes to everyone. - Arefin Bari [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
 
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 26-09-2014, 21:50
Zelda (Team702) Zelda (Team702) is offline
Registered User
FRC #0702
 
Join Date: Sep 2014
Location: Culver City
Posts: 2
Zelda (Team702) is an unknown quantity at this point
Setting an absolute value in Java

Hey everyone, I have a question that I've had for quite a while that no one seems to know the answer too. I'm a semi-new programmer for my team, I've been coding for them for about a year or so. I recently took charge of the programming subteam and have switched the team over to Java from C++. Now recently I was reprogramming our robot from Arial Assist and realized I have no idea how to set an absolute value in Java! In C++ I used to be able to use the fabs command, but it doesn't seem to work the same in Java.

If anyone knows the answer to my question please let me know. We are using Talons if that is of any use knowing. Thank you for taking the time to help another team out! I'll be FOREVER grateful.
Reply With Quote
  #2   Spotlight this post!  
Unread 26-09-2014, 23:02
Brian Selle's Avatar
Brian Selle Brian Selle is offline
Mentor
FRC #3310 (Black Hawk Robotics)
Team Role: Engineer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: Texas
Posts: 162
Brian Selle has a spectacular aura aboutBrian Selle has a spectacular aura aboutBrian Selle has a spectacular aura about
Re: Setting an absolute value in Java

Math.abs(<value>)
__________________
2015 Newton Semi-Finalist (3130, 2468, 3310, 537)
2015 Lubbock Regional Winner (2468, 3310, 4799)
2014 Galileo Quarter-Finalist (2052, 70, 3310, 3360)
2014 Colorado Regional Winner (1138, 3310, 2543)
2013 Texas Robot Roundup Winner (3310, 624, 2848)
2013 Archimedes Semi-Finalist (126, 3310, 1756)
2013 Dallas Regional Winner (148, 3310, 4610)
2012 Dallas West Regional Winner (935, 3310, 4206)
Reply With Quote
  #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
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 11:41.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi