Decimal to Binary

J

Javier Piñero

Hi,

I've been looking for a way of converting from decimal to binary in .NET
with C# but I haven't found anything. Is there any way?

Thanks in advanced.
 
A

Alex Feinman [MVP]

Can you elaborate on what you are trying to do? There are several ways to
represent a decimal number as binary. You can use packed decimal, fixed
point decimal, separately stored whole and decimal part... The internal
"decimal" type stores the number in three Int32-sized fields and keeps sign
and scale in a fourth one.
 
J

Javi

Hi Alex,

What I really want to do is to convert a number (19544877 for example) to
binary, it's not decimal as I said I'm sorry I was wrong, it's an integer.
So how should I do that??

Thanks again.
 
Z

Zanna

Javi ha scritto:
What I really want to do is to convert a number (19544877 for example) to
binary, it's not decimal as I said I'm sorry I was wrong, it's an integer.
So how should I do that??

All numbers are "binary" by themselves in information tecnology.

What you would to do I this is to convert a number into its *string*
binary rappresentation.

Simply do a loop on each bit of the variable and check if it is on.

Bye
 
J

Javi

Hello,

Yes Zanna what I want is "to convert a number into its *string*
binary rappresentation."
So what you mean with "Simply do a loop on each bit of the variable and
check if it is on", I don´t know how to do that I sure it's a stupid thing
but I can´t do that. Please can you post an example??

Thanks in advcanced
 
C

Chris Tacke, eMVP

Something like this?

http://wiki.opennetcf.org/ow.asp?BitRepresentationOfNumbers


--
Chris Tacke, eMVP
Co-Founder and Advisory Board Member
www.OpenNETCF.org
---
---
Principal Partner
OpenNETCF Consulting
www.OpenNETCF.com



Javi said:
Hello,

Yes Zanna what I want is "to convert a number into its *string*
binary rappresentation."
So what you mean with "Simply do a loop on each bit of the variable and
check if it is on", I don´t know how to do that I sure it's a stupid thing
but I can´t do that. Please can you post an example??

Thanks in advcanced
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top