![]() |
Inbuilt decimal to binary conversion function in C++
IS there any inbuilt decimal to binary conversion function in C++
|
Re: Inbuilt decimal to binary conversion function in C++
"Raja" <sharnakcl@yahoo.com> wrote in message news:b28e2ece.0406160600.3e050459@posting.google.c om... > IS there any inbuilt decimal to binary conversion function in C++ I think you mean to get binary representation of a given int. cout << bistset<10>(7); // 7 in binary with 10 bits -Sharad |
Re: Inbuilt decimal to binary conversion function in C++
Raja posted:
> IS there any inbuilt decimal to binary conversion function in C++ Well... all computers store data in binary. As such I pressume you're talking about strings, ie. "23" -> "00010111" Maybe something along the lines of: #include <stdlib.h> int main(void) { char binary_string[10]; unsigned short int number = 23; itoa(number,binary_string,2); //The 2 in the above specifies the radix, ie. the number of digits //in the number system. For decimal, this would be 10. For, octal, 8. //For Hexadecimal, 16. For binary, 2. } -JKop |
| All times are GMT. The time now is 12:29 AM. |
Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.