Hexadecimal to binary, decimal in c#
Author Message
Hexadecimal to binary, decimal in c#

Hi All,

What is the easiest way to do some number crunching in C#? (includes hexadecimal numbers and conversion to binary form and all) What all classes to use?

Regards,
Sunil

Mon, 31 Jan 2005 14:27:46 GMT
Hexadecimal to binary, decimal in c#
For conversion of the simple, built-in int/long to hex/bin :
int = Int32.Parse( "123" );           // dec string => int
int = Convert.ToInt32( "dead", 16 );  // hex string => int
string = int.ToString( "x" );         // int => hex string
string = Convert.ToString( int, 2 );  // int => binary string

checking for a valid number string:
double.TryParse(...)

For larger numbers then long/64-Bit, also check:
http://www.codeproject.com/useritems/BigInteger.asp

--
NETMaster  (Thomas Scheidegger)

What is the easiest way to do some number crunching in C#? (includes hexadecimal numbers and conversion to binary form and all) What
all classes to use?

Mon, 31 Jan 2005 15:11:34 GMT
Hexadecimal to binary, decimal in c#

Quote:

> What is the easiest way to do some number crunching in C#?
> (includes hexadecimal numbers and conversion to binary form and
> all) What all classes to use?

Convert.ToInt32 (String, int) would be a good bet. Note that this isn't
what's commonly known as number crunching, which is heavy-duty
maths/arithmetic rather than string conversion.

--

http://www.pobox.com/~skeet/

Mon, 31 Jan 2005 15:58:14 GMT
Hexadecimal to binary, decimal in c#
Hey Thanks for the help .....
I meant  I have to do some heavy-duty maths which involves this conversions
:)

Quote:

> > What is the easiest way to do some number crunching in C#?
> > (includes hexadecimal numbers and conversion to binary form and
> > all) What all classes to use?

> Convert.ToInt32 (String, int) would be a good bet. Note that this isn't
> what's commonly known as number crunching, which is heavy-duty
> maths/arithmetic rather than string conversion.

> --

> http://www.pobox.com/~skeet/
> If replying to the group, please do not mail me too

Mon, 31 Jan 2005 16:10:48 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages