Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7652227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T11:42:50+00:00 2026-05-31T11:42:50+00:00

I’ve been searching a while and haven’t gotten anything too useful yet, I’m working

  • 0

I’ve been searching a while and haven’t gotten anything too useful yet, I’m working on a subnet calculator, and well I have used the decimal to binary which I found here, though, I haven’t found a good way to convert binary to decimal.

Note: Remember its FROM binary TO decimal, anyways, im in need of the formula or something like that (meaning calculating it, not the automated one).

What I’ve understood by reading some other posts that you can somehow get the result by dividing by 10, but I didn’t really understand it, so if anyone could point me in the right direction, I’d be glad.

Any and all help is very much appreciated guys! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T11:42:51+00:00Added an answer on May 31, 2026 at 11:42 am

    Doing it without LINQ:

    var s = "101011";    // my binary "number" as a string
    var dec = 0;
    for( int i=0; i<s.Length; i++ ) {
      // we start with the least significant digit, and work our way to the left
      if( s[s.Length-i-1] == '0' ) continue;
      dec += (int)Math.Pow( 2, i );
    }
    

    A number in any base can be thought of as the sum of its digits multiplied by their place value. For example, the decimal number 3906 can be written as:

    3*1000 + 9*100 + 0*10 + 6*1
    

    The place values are simply powers of ten:

    3*10^3 + 9*10^2 + 0*10^1 + 6*10^0
    

    (Remember that any number taken to the power of zero is 1.)

    Binary works exactly the same way, except the base is 2, not 10. For example, the binary number 101011 can be written as:

    1*2^5 + 0*2^4 + 1*2^3 + 0*2^2 + 1*2^1 + 1*2^0
    

    I hope that gives you a better understanding of binary numbers and how to convert them.

    On a practical note, the best solution is Matt Grande’s; it’s always preferable to use a library method instead of rolling your own (unless you have a very good reason to do so).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.