0

What is the binary number data type?

I want to create a code using binary numbers in C++ but I do not know how to use binary numbers in C++. The data type and how to use it. Please help. Thank you :) Edit: Thank you for the answers. What is the language that has binary numbers usable data type like int double float

30th Jan 2017, 2:08 PM
NEVEN RAJ KAUNDER A/L SIVA RAJA -
NEVEN RAJ KAUNDER A/L SIVA RAJA - - avatar
2 Answers
+ 5
In C++ you can only write decimal, octal or hexadecimal numbers. But you still can write code that works with binary numbers :) To use octal numbers, you have to write "0" in front of every number. i.e. 010 (octal) = 8 (decimal) Hexadecimal is similar, you just put "0x" in front i.e. 0xB (hex) = 11 (dec) So, to work with binary numbers, you can basically use binary numbers written in other bases i.e. 11101001 = 0xE9 = 0351 = 233 I think it's best to use hex numbers because it's easiest to convert them to binary and vice versa :D P.S. use int data type to work with these numbers
30th Jan 2017, 3:04 PM
Eligijus Silkartas
Eligijus Silkartas - avatar
0
i don't know how to use binary in c++ but i can explain what is for you! A binary data type is also know as machine language and consist only of 0 and 1, every number in a sequence is called bit, and a sequence of 8 bit is called byte, for every byte we could have 256 diferente numbers (0-255) the sequency is make by power of 2, for the right to the left the values are 1,2,4,8,16,32,64,128. For example, if we pick up this sequence: 01000001 and convert this to ASCII we have te 'A' character! PS: sorry for my bad english, i'm brazilian.
30th Jan 2017, 2:53 PM
N1NJ4BR