View unanswered posts | View active topics It is currently Tue Sep 02, 2014 9:08 pm






Reply to topic  [ 2 posts ] 
random; rand(); 
Author Message
Rookie

Joined: Mon Nov 17, 2008 11:32 pm
Posts: 5
Post random; rand();
i am writing a code and i need both motors to go in at a random speed between -100 and 100. i tried

motor[lm] = rand(-100 - 100)
motor[rm] = rand(-100 - 100)

and several other things. is there a way to wright so that it will work?


Sun Aug 23, 2009 4:22 pm
Profile
Expert
User avatar

Joined: Tue Oct 14, 2008 7:16 pm
Posts: 171
Location: Investigating an unidentified ship sighted in Sector 31428
Post Re: random; rand();
Unfortunatly RobotC does not have a random number function, at least as of version 1.46; I can't speak for the latest version though. If there were it would look something like this,
Code:
rand(-100, 100);

Note the comma, as written your code would set the lower bound at -200, not specify bounds of -100 and 100.

P.S. There is no "ght" in write and when used as a pronoun "I" is capitalized. FYI :bigthumb:

_________________
Captain, Head programmer, School of the Arts, Silverbots Robtics Team #2890
Code:
using namespace System;
using namespace Genius;
using namespace Personality;
public ref class Nerd : Geek, IAnserable
{
    Geek::Type brainMode = Geek::Type::Programmer;
}


Sun Aug 23, 2009 8:06 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 2 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.