Author |
Message |
sophiesk101
Rookie
Joined: Thu Apr 11, 2013 6:11 pm Posts: 2
|
 Question...
Is it possible to make the robot round up?? Or does RobotC always round down with a number? Such as 2.777778 comes up as 2.00000.
|
Thu Apr 11, 2013 6:18 pm |
|
 |
Coder A
Moderator
Joined: Thu Jan 03, 2013 5:10 pm Posts: 207 Location: The plateau north of the Ohio River Valley, also known as Cave Country.
|
 Re: Question...
Of course. You will have to make your own function, though. Here's one: Does that help?
_________________ I'm not a robot! I'm british! ~ quote from an asparagus I am not a robot! I am a unicorn! ~ quote from a robot
Last edited by Coder A on Thu Apr 11, 2013 8:12 pm, edited 1 time in total.
|
Thu Apr 11, 2013 6:43 pm |
|
 |
sophiesk101
Rookie
Joined: Thu Apr 11, 2013 6:11 pm Posts: 2
|
 Re: Question...
|
Thu Apr 11, 2013 6:50 pm |
|
 |
Coder A
Moderator
Joined: Thu Jan 03, 2013 5:10 pm Posts: 207 Location: The plateau north of the Ohio River Valley, also known as Cave Country.
|
 Re: Question...
Good! I'm glad I could help.
_________________ I'm not a robot! I'm british! ~ quote from an asparagus I am not a robot! I am a unicorn! ~ quote from a robot
|
Thu Apr 11, 2013 8:11 pm |
|
 |
RoboDesigners
Novice
Joined: Sat Jul 10, 2010 3:06 pm Posts: 86 Location: Roanoke, VA
|
 Re: Question...
If you want an approach to round based on typical rules (e.g. 9.6 rounds up, 5.3 rounds down, 5.5 rounds up), you can try:
_________________Check out my website! www.RoboDesigners.comVRC Team 2190 Twitter: @RoboDesigners
|
Thu Apr 11, 2013 11:30 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Question...
Or.... you can just use the round() function in ROBOTC  = Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Fri Apr 12, 2013 12:53 am |
|
 |
NeXT-Generation
Senior Roboticist
Joined: Wed Sep 28, 2011 10:13 pm Posts: 630 Location: If I told you, I'd have to kill you.
|
 Re: Question...
Are we all understanding this question correctly? You want something that will always round up, or round up/down based on whether it's greater or less than x.5? I'm somewhat confused by all the different answers.
_________________A.K.A. inxt-generation Self-proclaimed genius, and future world dominator. My Brickshelf Folder"Don't they teach recreational mathematics anymore?" - The Tenth Doctor Bow down to Nikola Tesla, King of the Geek Gods.
|
Fri Apr 12, 2013 10:34 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Question...
If you want to round up, use ceil(), otherwise use floor(), if you want to round off, like most humans do, use round().
= Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Fri Apr 12, 2013 10:44 am |
|
|