View unanswered posts | View active topics It is currently Wed Apr 16, 2014 5:53 pm






Reply to topic  [ 8 posts ] 
Binary numbers on RobotC 
Author Message
Expert

Joined: Sun Sep 09, 2007 10:12 am
Posts: 116
Post Binary numbers on RobotC
I will need to know if there is or is planned to exist something like:

000011010b

or even

0b000011010

what i mean is the possibility of store on a byte a binary value.

THanks

_________________
http://www.apcsguarda.com
My Project: http://www.robotc.net/forums/viewtopic.php?f=15&t=712


Thu Sep 04, 2008 3:17 pm
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post Re: Binary numbers on RobotC
Currently ROBOTC recognizes decimal and hexadecimal constants. Hex constants are prefixed by the two characters "0x". For example, "0x20" is decimal 32.

With a little practice, it's pretty easy to convert between text numbers in binary and hexadecimal values.

ROBOTC does not currently support binary constants in "text strings".


Wed Sep 17, 2008 8:55 pm
Profile
Expert

Joined: Sun Sep 09, 2007 10:12 am
Posts: 116
Post Re: Binary numbers on RobotC
i know how to convert it, the problem sometimes is explain to kid's how to do it...

_________________
http://www.apcsguarda.com
My Project: http://www.robotc.net/forums/viewtopic.php?f=15&t=712


Thu Sep 18, 2008 4:02 am
Profile
Creator
Creator

Joined: Fri Feb 09, 2007 9:21 am
Posts: 614
Post Re: Binary numbers on RobotC
Quote:
I know how to convert it, the problem sometimes is explain to kid's how to do it...

OK. I understand this point and it was a very simply change. So I just added "binary" numeric constants to the ROBOTC compiler. They're of similar format to hex constants, i.e. precede the constant with "0b" or "0B" as in "0b11101".

NOTE: The standard C language (or C++) does not support this definition. They would generate a syntax error. This is an extension unique to ROBOTC.

This will appear in the next release of ROBOTC.


Thu Sep 18, 2008 6:47 am
Profile
Moderator
Moderator
User avatar

Joined: Wed Mar 05, 2008 8:14 am
Posts: 3105
Location: Rotterdam, The Netherlands
Post Re: Binary numbers on RobotC
Dick,

WinAVR has it, too :) See http://winavr.scienceprog.com/short-int ... guage.html for more info. I would love to see this notation and I am glad you've decided to implement them!

Regards,
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]


Thu Sep 18, 2008 7:21 am
Profile WWW
Expert

Joined: Sun Sep 09, 2007 10:12 am
Posts: 116
Post Re: Binary numbers on RobotC
Dick Swan wrote:
This will appear in the next release of ROBOTC.


There are things like this that keep me loving and using RobotC. A good forum, with excelent people and a excelent crew.

Thanks all

_________________
http://www.apcsguarda.com
My Project: http://www.robotc.net/forums/viewtopic.php?f=15&t=712


Thu Sep 18, 2008 11:49 am
Profile
Guru
User avatar

Joined: Sat Mar 01, 2008 12:52 pm
Posts: 1030
Post Re: Binary numbers on RobotC
docilio wrote:
A good forum, with excelent people and a excelent crew. Tanks all

You're welcome! :D

_________________
regards,
HaWe aka Ford
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;task main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PutPixel(x,y);}}}while(1)}


Thu Sep 18, 2008 1:19 pm
Profile
Moderator
Moderator
User avatar

Joined: Wed Jan 31, 2007 3:39 am
Posts: 299
Location: San Diego, California. USA
Post Re: Binary numbers on RobotC
ohh boy binary math!

B-)

_________________
Mmmm Legos B-)

My Robot Projects:
http://www.freewebs.com/robotprojects/


Sun Sep 21, 2008 5:33 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 8 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.