View unanswered posts | View active topics It is currently Sat Sep 19, 2020 12:11 pm

Reply to topic  [ 3 posts ] 
Declaring Binary Literals 
Author Message
User avatar

Joined: Sat May 18, 2013 1:24 pm
Posts: 271
Location: Olympia, WA
Post Declaring Binary Literals
I don't have access to RobotC right now. I'd like to know whether RobotC supports declaring binary literals like
byte x = 0b01101001;

According to Stack Overflow, GCC supports this.

FTC Team 6424, the 'Oly Cow - Chief programmer.
FRC Team 4450, Olympia Robotics Federation (ORF).

and also quadrotors. Quadrotors!

Tue Oct 29, 2013 7:53 pm
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: Declaring Binary Literals
Yep, this works.
task main()
    int data = 0b01101001;
    nxtDisplayTextLine(0, "d=%x", data);
    while (true)

It gives you "d=69".

Tue Oct 29, 2013 8:36 pm

Joined: Thu Sep 29, 2011 11:09 pm
Posts: 184
Location: Michigan USA
Post Re: Declaring Binary Literals
Which is correct. However, the format of that looks wrong. It should be noted that 0b01101001 = 0x69 (hex 69, not dec 69) = 105 (decimal).

Whenever I display hex values, just to be clear, I like to precede them with 0x, e.g.
nxtDisplayTextLine(0, "d=0x%x", data);
which should print "d=0x69".


Tue Oct 29, 2013 9:25 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 3 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.