ROBOTC.net forums
http://robotc.net/forums/

Binary numbers on RobotC
http://robotc.net/forums/viewtopic.php?f=1&t=713
Page 1 of 1

Author:  docilio [ Thu Sep 04, 2008 3:17 pm ]
Post subject:  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

Author:  Dick Swan [ Wed Sep 17, 2008 8:55 pm ]
Post subject:  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".

Author:  docilio [ Thu Sep 18, 2008 4:02 am ]
Post subject:  Re: Binary numbers on RobotC

i know how to convert it, the problem sometimes is explain to kid's how to do it...

Author:  Dick Swan [ Thu Sep 18, 2008 6:47 am ]
Post subject:  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.

Author:  mightor [ Thu Sep 18, 2008 7:21 am ]
Post subject:  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

Author:  docilio [ Thu Sep 18, 2008 11:49 am ]
Post subject:  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

Author:  Ford Prefect [ Thu Sep 18, 2008 1:19 pm ]
Post subject:  Re: Binary numbers on RobotC

docilio wrote:
A good forum, with excelent people and a excelent crew. Tanks all

You're welcome! :D

Author:  starwarslegokid [ Sun Sep 21, 2008 5:33 pm ]
Post subject:  Re: Binary numbers on RobotC

ohh boy binary math!

B-)

Author:  kidingwithlaura [ Tue Mar 01, 2016 11:36 am ]
Post subject:  Re: Binary numbers on RobotC

Well I use any online tool for binary conversion, among all I prefer rapid tables converter when I need to know the method as well as it do tell the calculations also, this tool is nice and I got to know about this recently. I would like to give some credit to that source, I found this tool here on this post on focusandleap.

Thank You

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/