[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
Solved

what is the symbol to mention as binary in c language  ?

Posted on 2012-08-28
Medium Priority
497 Views
16 -> equalant hexa decimal 0x10
12 -> equalant octal         010
10 -> what is equalant for binary  ?

before "0x" is to mention hexadecimal
before "0" is to mention octal
before "?"  what is the symbol to mention binary ?
0
Question by:softwareachiever

LVL 20

Assisted Solution

thehagman earned 450 total points
ID: 38340351
There is none. The C standard allows only octal, decimal and hex number literals.
It is however fairly easy to write a given binary number as hex or octal number: simply group the digits in groups of 3 (for otal) or 4 (for hex) starting from the right and convert these single digits in your head.
E.g. to write the 1001101101 goup this to  1,001,101,101, hence write 01155.
Or group 10,0110,1101 and hence write 0x26d.
0

LVL 13

Assisted Solution

Ryan earned 450 total points
ID: 38340556
I would recommend learning it, but the calculator on Win7 does it, as well as Google.
Search "1001011 to hex"

But yes, I found it annoying when doing bit masking in VB.NET as well.
0

LVL 32

Accepted Solution

phoffric earned 600 total points
ID: 38342231
Since there is no symbol like 0x for hex to express binary, if you have a binary value in a text string, then you can convert it to decimal or hex yourself with your own function(s). Here are some links to consider so that you do not have to start from scratch:
http://www.cplusplus.com/reference/clibrary/cstdlib/strtoul/
http://www.cplusplus.com/forum/windows/35848/
0

Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses
Course of the Month19 days, 21 hours left to enroll