Does c++ gt a special function for conversion between decimal to binary or decimal to hexadecimal and others???![]()
Decimal to binary is a simple enough equation that you can create it yourself. Divide your decimal number by 2 and take the remainder. You can do this using the modulus (%) operator. Keep doing this until the decimal number = 0.
In .NET you can use:Code:(int) BinaryMod = decimalNumber %2; (String) BinaryDisplay += BinaryMod; decimalNumber / 2;
Where DecimalValue is your decimal number and 2 is your base. Using that function you can convert to any base.Code:Convert.ToString(DecimalValue, 2).PadLeft(8, "0")
thanks jordan, for decimal and octo i done it edi...but for hexadecimal....i still dunno how to convert d 10,11,12....to alphabet...i just can manage to show their ASCII code...how to do it????![]()
You need to convert the base to 16 for hexadecimal. I found some C# code which does this and you should be able to convert it to Manage C++ code very easy: How to convert string to hexadecimal and vice versa
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks