Welcome to Dream.In.Code
Getting C# Help is Easy!

Join 136,549 C# Programmers for FREE! Get instant access to thousands of C# experts, tutorials, code snippets, and more! There are 1,858 people online right now. Registration is fast and FREE... Join Now!




Binary Calculator

 
Reply to this topicStart new topic

Binary Calculator

JBrace1990
22 Aug, 2008 - 09:53 PM
Post #1

D.I.C Regular
Group Icon

Joined: 9 Mar, 2008
Posts: 476



Thanked: 22 times
Dream Kudos: 350
My Contributions
i'm looking to make a Binary Calculator, but I need some help with the logic...

now, I was thinking of using a For loop, starting at 1237940039285380274899124224 (which is 2^90, or 1 Brontobyte (apparently the largest type of data storage), and go down from there... I figure keep dividing it by 2 until you get a number you can take out of the binary number, and then continue from there...

only problems are the following:
1. I don't think C# variables can hold that much information...
2. If they can, wouldn't it crash REALLY badly? =/

the other option is to start much lower, probably an exabyte (2^60 ) and do it from there? (exabyte is 1 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 in binary btw =) )

so basically, my logic is convert it into decimal and then figure it out from there... but there has to be a better way, right?
User is offlineProfile CardPM
+Quote Post

baavgai
RE: Binary Calculator
23 Aug, 2008 - 05:52 AM
Post #2

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,031



Thanked: 105 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions
You'll have to implement your own "BigInt" kind of class, or find one. Absurdly huge numbers are a staple of cryptography and libraries abound. Since C# syntax is really close to C++ when it comes to bit manipulation, you can probably use so very established stuff.

There is a canned BigInteger class in C# that should do what you need, if you don't want to roll your own.

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 11:06PM

Live C# Help!

C# Tutorials

Reference Sheets

C# Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month