| 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
Expert
Joined: Thu Jan 03, 2013 5:10 pm Posts: 138 Location: Southern Indiana
|
 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 asparagusI am not a robot! I am a unicorn! ~ quote from a robotPlay chess for free!
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
Expert
Joined: Thu Jan 03, 2013 5:10 pm Posts: 138 Location: Southern Indiana
|
 Re: Question...
Good! I'm glad I could help.
_________________I'm not a robot! I'm british! ~ quote from an asparagusI am not a robot! I am a unicorn! ~ quote from a robotPlay chess for free!
|
| 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
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 Location: Rotterdam, The Netherlands
|
 Re: Question...
Or.... you can just use the round() function in ROBOTC  = Xander
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| 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: 510 Location: Totally not spying on Hassenplug to see what he has for the Brickworld Chicago 2013 sumo contest.
|
 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
Moderator
Joined: Wed Mar 05, 2008 8:14 am Posts: 2864 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
_________________| Some people, when confronted with a problem, think, "I know, I'll use threads," | and then two they hav erpoblesms. (@nedbat)| My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
| Fri Apr 12, 2013 10:44 am |
|
|