This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

binary notation

I just started using keil c51 compiler.
Since I know that keil is compatible to ANSI-C
I want to know if there is an ANSI-C
compatible notation for binary numbers.

Like when I want to write the number in hexadecimal notation
I use the prefix "0x"
->
0xFF

All oher numbers are considered to be in
decimal notation.
->
1234567890

But which prefix do I use for binary number system?

I already tried (0b..., ...b, ...) and got
->error C251: illegal octal digit
->error C141: syntax error near 'b'
...

By the way, it would be nice to know which notation to use for octal number systems.

Regards
J.

  • "I want to know if there is an ANSI-C compatible notation for binary numbers."

    There is a very simple and straightforward answer to this:

    NO!

    "I just started using keil c51 compiler."

    It sounds like you have just started using any form of 'C'?

    The 'C' programming language has never supported a binary notation, so no decent textbook would have given you the idea that it did.

    "it would be nice to know which notation to use for octal number systems"

    Now this is absolutely standard 'C' stuff - see any good 'C' textbook.

    It sounds like you really need to get yourself a good 'C' textbook, and actually take some systematic approach to learning the language

    Here are some book lists:
    http://www.keil.com/books/8051books.asp
    http://www.8052.com/books.phtml

    If possible, you should do a taught 'C' training course.
    If you say where you are, people may be able to recommend one.

  • Do not make the mistake of buying another "C and '51" book.

    Those books do NOT teach you C, they are "the 51' for programmers already versed in C".

    A good self-teach book would be Kochan: "Programming in ANSI C".

    It is so much easier to learn the C fundamentals on the PC than on a '51.

    PS: there are posts here or on 8052.com about free Borland C compilers for the PC which will allow you to work through the examples

    Erik

  • "PS: there are posts here or on 8052.com about free Borland C compilers for the PC which will allow you to work through the examples"

    One thing to beware of is that they're probably C++ compilers, and/or C99.

    Most embedded 'C' compilers (including C51) are the "original" ANSI 'C'

    Both C++ and C99 will accept "original" ANSI 'C', but will let you get away with things that a true "original" ANSI 'C' does not allow.

    There's often an option to enable "pure ANSI" mode...