| | |
binary to decimal
Please support our C# advertiser: Intel Parallel Studio Home
Thread Solved |
Try first to write your solution in a draft, think how to code it, all of us know how to convert it theoretically, which means you won't pay a lot to think, and to code; it's for your interest to do it yourself, some lines of codes won't help you as they are not written by you!!
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
You have a huge number of ways to do it.
You could either tackle it as a human would, or, you look though the helpfile and see if theres a prebuilt way to do it.
Either way, get some ideas on paper, try and code it, and then when you have something... We'll help.
You could either tackle it as a human would, or, you look though the helpfile and see if theres a prebuilt way to do it.
Either way, get some ideas on paper, try and code it, and then when you have something... We'll help.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Jun 2008
Posts: 58
Reputation:
Solved Threads: 9
.NET even has a built-in function to do the conversation. Some basic research would tell you the answer
Visual C# Kicks - Free C# code resources and articles.
•
•
Join Date: Dec 2008
Posts: 104
Reputation:
Solved Threads: 18
From Decimal to Binary..
From Binary to Decimal...
using System;
class Program{
static void Main(string[] args){
try{
int i = (int)Convert.ToInt64(args[0]);
Console.WriteLine("\n{0} converted to Binary is {1}\n",i,ToBinary(i));
}catch(Exception e){
Console.WriteLine("\n{0}\n",e.Message);
}
}//end Main
public static string ToBinary(Int64 Decimal)
{
// Declare a few variables we're going to need
Int64 BinaryHolder;
char[] BinaryArray;
string BinaryResult = "";
while (Decimal > 0)
{
BinaryHolder = Decimal % 2;
BinaryResult += BinaryHolder;
Decimal = Decimal / 2;
}
// The algoritm gives us the binary number in reverse order (mirrored)
// We store it in an array so that we can reverse it back to normal
BinaryArray = BinaryResult.ToCharArray();
Array.Reverse(BinaryArray);
BinaryResult = new string(BinaryArray);
return BinaryResult;
}
}//end class ProgramFrom Binary to Decimal...
C# Syntax (Toggle Plain Text)
using System; class Program{ static void Main(string[] args){ try{ int i = ToDecimal(args[0]); Console.WriteLine("\n{0} converted to Decimal is {1}",args[0],i); }catch(Exception e){ Console.WriteLine("\n{0}\n",e.Message); } }//end Main public static int ToDecimal(string bin) { long l = Convert.ToInt64(bin,2); int i = (int)l; return i; } }//end class Program
![]() |
Similar Threads
- Number System:Conversion from binary to decimal (C)
- binary to decimal in c++ code (C++)
- How do I Take in Hexidecimal input out put binary, decimal, and octal (Java)
- i need code for binary to decimal (it should be written in 'C') (C)
Other Threads in the C# Forum
- Previous Thread: Formatiing Hard Drives programatically using C#
- Next Thread: Detect Mouse Click Anywhere on Window, Not just on form
| Thread Tools | Search this Thread |
.net access ado.net algorithm array backup barchart bitmap box broadcast buttons c# check checkbox client clock color combobox control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing dynamiccreation encryption enum event excel file form format forms function game gdi+ httpwebrequest image index input install interface java label list listbox mandelbrot math microsystems mouseclick mysql operator password path photoshop picturebox pixelinversion post programming property radians regex remote remoting richtextbox running... serialization server sleep soap socket sql sqlserver stack statistics stream string table text textbox thread time timer update usercontrol validation visualstudio webbrowser windows winforms wpf write xml






