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)
  http://www.cetus-links.org/oo_csharp.html

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/
If replying to the group, please do not mail me too



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  
 
 [ 4 post ] 

 Relevant Pages 

1. Convert from binary to decimal, hex to decimal etc

2. hexadecimal is more logical than decimal

3. How i can make Hexadecimal to Decimal Conversion With C#

4. how to convert a decimal number to an hexadecimal

5. decimal > hexadecimal

6. (newbie) Convert decimal to hexadecimal?

7. How to convert hexadecimal to decimal

8. Decimal value in hexadecimal in C++?

9. Decimal value in hexadecimal in C++?

10. decimals -> one hexadecimal number

11. hexadecimal to binary help

12. Command or function for converting hexadecimal to binary

 

 
Powered by phpBB® Forum Software