Keil Logo

Entering and viewing binary numbers

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Author
ro whiffin
Posted
9-Oct-2018 16:37 GMT
Toolset
ARM
New! Entering and viewing binary numbers

Using:
uVision 5
*** Using Compiler 'V5.06 update 6 (build 750)', folder: 'C:\Keil\uVision5\ARM\ARMCC\Bin'

I'm trying to make a variable equal to a binary number, something like:

unsigned char Number = 0b00001111;

The IDE doesn't show any issues on the screen, but the compiler comes back with this error:

..\ZCU\source\code\Debug_rW.c(67): error: #19: extra text after expected end of number

How do I get round this?

Secondly, I which to view that "Number" in a watch window as a binary number, is this possible? I can only see Hex and Decimal as an option.

Many thanks for any input.

Regards, R

Author
Brandon Price
Posted
9-Oct-2018 18:04 GMT
Toolset
None
New! RE: Entering and viewing binary numbers

Did you try using the 'y' or 'Y' suffix?

See this link: http://www.keil.com/support/man/docs/uv4/uv4_db_exp_constants.htm

Author
r w
Posted
10-Oct-2018 09:45 GMT
Toolset
None
New! RE: Entering and viewing binary numbers

Yes, doesn't work.

Thanks.

Author
Andrew Neil
Posted
9-Oct-2018 20:55 GMT
Toolset
None
New! RE: How do I get round this?

You would have to choose a different programming language - 'C' does not support binary literals in source code.

Nothing to do with Keil or ARM.

However, as noted, you can set the debugger to display in binary.

Author
Andrew Neil
Posted
9-Oct-2018 21:04 GMT
Toolset
None
New! RE: 'C' does not support binary literals

Well, it has, apparently, been added to the C++14 standard:

http://stackoverflow.com/questions/16334024/difference-between-gcc-binary-literals-and-c14-ones

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3472.pdf

http://stackoverflow.com/questions/18244726/why-doesnt-c-have-binary-literals

Author
r w
Posted
10-Oct-2018 09:44 GMT
Toolset
None
New! RE: How do I get round this?

However, as noted, you can set the debugger to display in binary.

How do you do the above?

Many thanks.

Author
Andrew Neil
Posted
10-Oct-2018 10:23 GMT
Toolset
None
New! RE: How do you do the above?

Did you not follow the link provided by Brandon Price ?

Author
r w
Posted
11-Oct-2018 09:22 GMT
Toolset
None
New! RE: How do you do the above?

Yes, I have followed various links... the Suffix "y" or "Y" does not work.

Is there a way of showing a variable as binary in the watch window?

Thanks

Author
Andrew Neil
Posted
11-Oct-2018 10:14 GMT
Toolset
None
New! RE: How do you do the above?

Show exactly what you actually did, and the results you got.

Author
coy martin
Posted
24-Oct-2018 08:14 GMT
Toolset
None
New! RE: How do you do the above?

[url=http://bbc.com]bbc[/url]
<a href="http://bbc.com">bbc</a>

Author
Ron Wedge
Posted
2-Nov-2018 06:50 GMT
Toolset
ARM
New! RE: Entering and viewing binary numbers

C Does not typically provide a way to enter Binary representation of a number, but you could write a macro to do this:

http://www.keil.com/support/docs/1156.htm

Or use the octal notation trick

http://www.keil.com/forum/21497/how-to-input-a-binary-number/

If you are using ARM Compiler 6, you can use ARM Assembly to write a Binary Literal:

https://developer.arm.com/docs/100068/0608/migrating-from-armasm-to-the-armclang-integrated-assembler/numeric-literals

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.