Converting 1100110.11 to base10

This is a discussion on Converting 1100110.11 to base10 within the General Discussions forums, part of the Community Boards category; No, quzah. You're falling into the same trap as the others arguing about machine representation. The OP wanted to know ...

  1. #16
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    No, quzah. You're falling into the same trap as the others arguing about machine representation. The OP wanted to know how to deal with the written binary number that has a fractional part. And yes, you could shift the period left or right (like dividing by 2 or multiplying by 2).

    The fact that C compilers complain when you attempt a shift (<< or >>) on a floating point data type does not alter the fact that yes, one could shift the 32 or 64 bit value, but since it's a mixture of biased exponent and significand without most significant bit... it would most likely break the number. Actually it would most closely resemble a squaring or square-rooting operation.

    1100110.11 is 102.75
    110011.011 is 51.375 see? Yay, shifting the "decimal" works.

    (My mistake, 0.11 is 0.75... I said 0.375 earlier.)
    Last edited by nonoob; 01-31-2011 at 02:03 PM.

  2. #17
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Oh, and has anybody figured out what we're being warned against?

  3. #18
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    Heh heh, good one. For a minute I thought you wanted to know what the compiler warning is for attempting to shift a floating point.

  4. #19
    Registered User
    Join Date
    Oct 2008
    Posts
    1,262
    For anyone wanting to argue, Wikipedia is always right and it shows examples of it:
    Binary numeral system - Wikipedia, the free encyclopedia

  5. #20
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by nonoob View Post
    No, quzah. You're falling into the same trap as the others arguing about machine representation.
    No. You're falling into your own trap by saying binary is more than just 1s and 0s. It's not. Binary is just 1s and 0s. There is no "one or zero or decimal point". It's either one, or zero. That's all. There is nothing else.

    Anything else is YOUR representation, which no different than you saying "you are interpreting how it's stored in memory!" There is no such thing in binary as a decimal place. It's YOU adding something more to binary. Binary is only ever 1 or 0. There's no place holder. That's you adding an extension to it.

    Go read the entire first half of the Wikipedia article on it, and you'll see I'm right. There's nothing in binary that denotes a decimal point. That's an extension of binary. It's like saying your compiler supports extensions to let you use nested comments or something. That doesn't make it part of the core system, just because you extended it.

    The concept of binary knows nothing of decimal places. It is simply 0s or 1s.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #21
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by quzah View Post
    No. You're falling into your own trap by saying binary is more than just 1s and 0s. It's not. Binary is just 1s and 0s. There is no "one or zero or decimal point". It's either one, or zero. That's all.
    If you actually believe that, then there's no decimal point in decimal, either, just zero through nine.

  7. #22
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,566
    Quote Originally Posted by quzah View Post
    No. You're falling into your own trap by saying binary is more than just 1s and 0s. It's not. Binary is just 1s and 0s. There is no "one or zero or decimal point". It's either one, or zero. That's all. There is nothing else.

    Anything else is YOUR representation, which no different than you saying "you are interpreting how it's stored in memory!" There is no such thing in binary as a decimal place. It's YOU adding something more to binary. Binary is only ever 1 or 0. There's no place holder. That's you adding an extension to it.
    That's like saying numbers in base 10 are nothing more than a bunch of 0's, 1's, 2's, 3's, 4's, 5's, 6's, 7's, 8's, and 9's, with no place holder. But we obviously use our decimal number system to represent whole and fraction quantities all the time, by using an eleventh symbol, . which we also call the decimal point. It has no quantitative value in and of itself, but it does separate the whole quantity from the fractional quantity. A single digit on it's own (say 5), out of context can't represent one half of something, but you put it in the right place relative to the conventional . used for the whole-part separator, and 5 becomes .5, or one half (5 * 10^-1). Similarly, .1 in binary is 1 * 2^-1, or one half. Perhaps people are mixing up the concept of numbers vs. numerals.

    Go read the entire first half of the Wikipedia article on it, and you'll see I'm right. There's nothing in binary that denotes a decimal point. That's an extension of binary. It's like saying your compiler supports extensions to let you use nested comments or something. That doesn't make it part of the core system, just because you extended it.
    Read it, still don't see how it proves you're right. As a matter of fact, the same article shows exactly how to represent non-whole numbers in base two. Same principle as in base 10 or any other base, just with powers of two instead of 10. Nobody is extending anything. What we're discussing is a number system not restricted by a computer's internal representation or some fanciful notion that a binary system can't have a whole-part separator because the symbol we would use for that is neither a 0 nor a 1.

    The concept of binary knows nothing of decimal places. It is simply 0s or 1s.
    Binary by definition simply implies two-ness. In a binary, or base 2 number system, that means there are two possibilities for a digit, conventionally 0 or 1, but it could be anything. Sometimes we refer to it as high and low values or on and off. On a lower level, the computer doesn't see 0's and 1's, it sees voltage levels, like 5V or 3.3V for a value of "1". All that matters in binary is that there are two distinct values for a single digit. Just like base 10 has 10 distinct values for a digit.

  8. #23
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,249
    If you want to get all pedantic about it, there are no "ones and zeros" in a computer either. A computer is made of atoms.

    When's the last time you "saw" a number? The only place that numbers, decimal points, and fractions exist is... in your head.

    In any left-to-right positional number-writing system, each digit represents x*b^N, where x is a digit within that system, b is the base of the system, and N is some integer which decreases from left to right. The decimal point means "the digit to my left has N == 0". The computer doesn't care about ANY of this.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  9. #24
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,596
    Change the title of this post please. There is no urgency here. Also read the rules about creating such titles.

  10. #25
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Prove it. Use strtol with a base 2 and have it handle your decimal point. Go on, show me how it's really not YOU just interpreting how you want to treat those 1s and 0s. Prove it.

    There's a reason you can't treat floats as regular integer types of the same number of bits. You can't pretend you're treating it in the context of a program, and pretend you aren't at the same time. You can't try to be a purist on what binary actually means, and then try not to at the same time.


    Quzah.
    Last edited by quzah; 01-31-2011 at 06:44 PM.
    Hope is the first step on the road to disappointment.

  11. #26
    Captain Crash brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,249
    Quote Originally Posted by quzah View Post
    Prove it. Use strtol with a base 2 and have it handle your decimal point. Go on, show me how it's really not YOU just interpreting how you want to treat those 1s and 0s. Prove it.
    That will reveal some interesting information about what strtol() is and is not capable of, and absolutely nothing about the nature of binary numbers.
    Code:
    //try
    //{
    	if (a) do { f( b); } while(1);
    	else   do { f(!b); } while(1);
    //}

  12. #27
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by brewbuck View Post
    That will reveal some interesting information about what strtol() is and is not capable of, and absolutely nothing about the nature of binary numbers.
    Well the whole discussion really is about if you are trying to read integers, or floats. No one assumes that binary input is a floating point number, because that's a stupid way to do it.


    Quzah.
    Last edited by quzah; 01-31-2011 at 08:06 PM.
    Hope is the first step on the road to disappointment.

  13. #28
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by quzah View Post
    You can't pretend you're treating it in the context of a program, and pretend you aren't at the same time.
    Quzah.
    Free bonus hint: You are the only person in this thread talking about a program. What was that about context, again?

  14. #29
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by tabstop View Post
    Free bonus hint: You are the only person in this thread talking about a program. What was that about context, again?
    I see. That's odd, because I'm pretty sure I'm on a C programming forum. Anyway, if we pretend this is somehow a math forum instead, and we actually look at the OP:
    how to solve this .....1100110.11 to base10?

    help meee
    The thing is there's nothing here in the OP that says what the source format is, so it's perfectly fine for me to say that's not binary, and that it's already base 10. Furthermore, no one I've ever talked to on a programming forum has ever taken a string of 1s and 0s, and has stuck a decimal point in the middle of it. It's a mess of a conversation. But if you want to put decimal points in your binary numbers, go ahead.


    Quzah.
    Hope is the first step on the road to disappointment.

  15. #30
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by quzah View Post
    The thing is there's nothing here in the OP that says what the source format is, so it's perfectly fine for me to say that's not binary, and that it's already base 10.
    That would be a perfectly wonderful response, if for no other reason that to get the OP to say what he really wants.

    Furthermore, no one I've ever talked to on a programming forum has ever taken a string of 1s and 0s, and has stuck a decimal point in the middle of it.
    Quzah.
    (EDIT: Okay this was originally a stupid comment. Stupid and pointless and stupid. I'm sorry.)
    Last edited by tabstop; 01-31-2011 at 09:40 PM.

Page 2 of 7 FirstFirst 1234567 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Converting decimals to individuals
    By clag in forum C Programming
    Replies: 27
    Last Post: 10-03-2009, 03:08 PM
  2. Replies: 1
    Last Post: 09-20-2009, 07:39 AM
  3. Converting Sign Magnitude Integer Binary Files
    By Arthur Dent in forum C Programming
    Replies: 7
    Last Post: 09-13-2004, 10:07 AM
  4. Converting from Screen to World Coordinates
    By DavidP in forum Game Programming
    Replies: 9
    Last Post: 05-11-2004, 12:51 PM
  5. converting string to float
    By twhubs in forum C Programming
    Replies: 1
    Last Post: 09-16-2001, 09:02 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21