Archived

This topic is now archived and is closed to further replies.

binary number representation in c#

This topic is 5047 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

You can convert your number in binary notation to hexadecimal.

Each hex digit represents 4 binary digits. Or you can think
of it as every 2 hex digits is a byte, so that''s 8 binary digits.



Kami no Itte ga ore ni zettai naru!

Share this post


Link to post
Share on other sites
If you need the binary representation just for interfacing with the user (reading/writing values to/from screen or file) you can use one of those fuctions to convert strings to numbers (or vice-versa), stating that the conversion should be done using base 2.

If you need that representation to code something like int i = 01010b, then i don''t think C# supports that.

Blew

Share this post


Link to post
Share on other sites
From the C# Language Specification:
quote:

2.4.4.2 Integer literals

Integer literals are used to write values of types int, uint, long, and ulong. Integer literals have two possible forms: decimal and hexadecimal.


Share this post


Link to post
Share on other sites