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; I can't really see what any fuss is about. If the OP asks for convert "1100110.11" to base 10 then ...

  1. #31
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,304
    I can't really see what any fuss is about.

    If the OP asks for convert "1100110.11" to base 10 then seeing as how he has placed a decimal point there, he has clearly chosen to treat the bits to the right of it as fractional places.

    The answer of how to convert it is to treat each digit position as a power of two, assuming it is binary originally, and then sum them all up.

    For a number where the digits are ...ABCDEFG.HI..., the answer is:
    ... A*2^6 + B*2^5 + C*2^4 + D*2^3 + E*2^2 + F*2^1 + G*2^0 + H*2^-1 + I*2^-2 ...
    (where ^ denotes the power function)
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  2. #32
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    quzah, it is clear you have had no formal education in number systems. Perhaps all of your exposure to base 2 has been only within the context of what C library functions provide.

    Number systems of any base can represent whole numbers and fractions. I can look for many examples where the "decimal point" is indeed included in definitions of systems other than base-10.

    In this description for example:
    Binary Number System

    "Numbers can be placed to the left or right of the point, to indicate values greater than one or less than one. The number to the left of the decimal point is a whole number (10 for example). As we move further left, every number place gets 2 times bigger. The first digit on the right means halves (1/2). As we move further right, every number place gets 2 times smaller (half as big)."

    But back to the Wiki article, it calls the period a "binary point". "Binary numbers can also be multiplied with bits after a binary point:..." and then gives an example of long-hand multiplication by doing 5.625 x 6.25 in binary.
    Last edited by nonoob; 02-01-2011 at 07:26 AM.

  3. #33
    Registered User
    Join Date
    Sep 2006
    Posts
    8,868
    I believe iMalc** and others who support decimal points and digits to the right side of that decimal point are quite right. That is the standard for base 10. Other bases are no different in that respect.

    I believe Quzah is also correct, from a usage point of view. I've never heard of base 2 numbers which included a decimal point. Yes, it could happen, but experience says it's not likely to happen. We simply don't think of numbers less than one, in a base 2 format.

    When I first saw that decimal point in the binary number, I thought it was a speck of dirt on my monitor.

    I'd prefer not having these "evaluations" of what kind of education other forum members have, posted. It has the effect of directing the topic away from the subject, and into personal matters.

    **Excellent post on this, iMalc.
    Last edited by Adak; 02-01-2011 at 07:56 AM.

  4. #34
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,734
    Quote Originally Posted by tabstop
    Free bonus hint: You are the only person in this thread talking about a program. What was that about context, again?
    I agree. I am moving this thread to General Discussions as what minimal context was provided makes it seem much more of a maths question than a C programming question.

    hakimstm1b, if this is really supposed to be a C programming problem, then please start a new thread in the C programming problem with a better description of your problem along with your best attempt to solve it.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #35
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by nonoob View Post
    quzah, it is clear you have had no formal education in number systems. Perhaps all of your exposure to base 2 has been only within the context of what C library functions provide.
    This is true. I have only ever used them to manipulate bits.
    Quote Originally Posted by iMalc View Post
    I can't really see what any fuss is about.

    If the OP asks for convert "1100110.11" to base 10 then seeing as how he has placed a decimal point there, he has clearly chosen to treat the bits to the right of it as fractional places.
    The problem is that you cannot assume a number that only consists of 1s and 0s is binary (since all you are is seeing it as a string here).

    What's this number?

    101

    Or this number:

    10


    If you said one hundred one, and ten, then you might have been right. Of course you just as easily could have been wrong too. Especially if my post had started with "What's this number?" and ended at "10".


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

  6. #36
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    4,261
    O_O

    Okay, despite the fact that I know this stuff, it must be said: a thank you to tabstop, iMalc, nonoob, and anduril462.

    Soma

  7. #37
    Reverse Engineer maxorator's Avatar
    Join Date
    Aug 2005
    Location
    Estonia
    Posts
    2,318
    Quote Originally Posted by quzah View Post
    No there aren't. That's why you can't use shift operators on a float.
    All bases can be treated equally. Mathematically no bases have any "special privileges". Therefore, nonoob is right.
    "The Internet treats censorship as damage and routes around it." - John Gilmore

  8. #38
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by maxorator View Post
    All bases can be treated equally. Mathematically no bases have any "special privileges". Therefore, nonoob is right.
    Not in C they aren't, which is where this thread was initially posted.


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

  9. #39
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    Quote Originally Posted by Adak View Post
    I'd prefer not having these "evaluations" of what kind of education other forum members have, posted. It has the effect of directing the topic away from the subject, and into personal matters.
    No disrespect intended. And I don't think quzah ever took it to be insulting. No 'formal' education simply means not having gone through a classroom setting in mathematical theory. Instead, having not encountered a "binary point" is simply a reflection of what is encountered in day-to-day practical C programming.

    Quite right, the OP did not specify the incoming number base, although it is implied it is NOT base 10 as that was the desired target. Base 2 was assumed but probably safely so.

  10. #40
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,467
    Not overly excited by seeing a floating point sign in a binary representation myself. I'd rather preferred if the OP teacher had explained to him the IEEE 754 binary representation and he was now asking us about such a datum.

    For all purposes this bit representation with a floating point sign is entirely useless and will teach him nothing.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  11. #41
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    435
    Quote Originally Posted by Mario F. View Post
    For all purposes this bit representation with a floating point sign is entirely useless and will teach him nothing.
    It will teach him to represent any arbitrary number in any arbitrary base. It might not have any direct practical application to programming or computer science, but I think learning to generalize a concept leads to a better overall understanding of it.
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

  12. #42
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,832
    I tend to agree with NeonBlack.

    Teaching that base 10 is a myopic way to look at the world will open up your mind to issues of scaling, precision, input/output conversions, logarithms, round off error, etc. If the student becomes comfortable with how a digit's position determines exponent, then they are ready to write programs that can do any base conversions, to and from base 10.

    Understanding how a binary point works will make it simple to understand IEEE 754's exponent field.

    I don't think starting with IEEE 754 format would make generalization of the math involved easier.

  13. #43
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,467
    Quote Originally Posted by nonoob View Post
    I don't think starting with IEEE 754 format would make generalization of the math involved easier.
    I don't see how this format will make it easier. It offers no shortcut that I can see. No new information that isn't already available through traditional base 10 representation. It's not because I put a floating point in a binary representation that suddenly one has an eureka moment. What's worse, the conversion technique is a gimmick that simply inverts the technique used for the integral part. It does not provide any new knowledge and the whole thing will have to be relearned when it comes the time one really has to understand floating point binary representation in a computer.

    I entirely fail to see the value of this. It cannot be applied in any way. So it fails as a generalization. A generalization would save important knowledge when it came the time to get into the specifics. But this representation saves instead the wrong knowledge. In other words, what he learned here cannot be applied to what he will have to learn later.

    Binary representation of floating point numbers differs greatly from binary representation of integer numbers. It has in fact... surprise... a lot more in common with decimal representation of floating point numbers. If you want a good generalization, there you have it. It's a lot easier to make a student understand floating-point representation in binary format by showing them this simple decimal representation, and starting from there:

    314.1592 X 10^-2

    Pretty much everything they need to know is represented here.
    Last edited by Mario F.; 02-01-2011 at 02:55 PM.
    The programmer’s wife tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.”
    The programmer comes home with 12 loaves of bread.


    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  14. #44
    Devil's Advocate SlyMaelstrom's Avatar
    Join Date
    May 2004
    Location
    Out of scope
    Posts
    4,069
    Quote Originally Posted by NeonBlack View Post
    It will teach him to represent any arbitrary number in any arbitrary base. It might not have any direct practical application to programming or computer science, but I think learning to generalize a concept leads to a better overall understanding of it.
    While that might be what you're comfortable with, it's simply not how this forum, or most forums for that matter, have historically worked. Topics are answered with in the context of the forum. If someone were to post a question about history or literature in the C programming forum, then perhaps you might not feel comfortable answering it because you identify that it is not related to programming. This is no different... the fact is that you and many others here simply seem to feel that math is "close enough" to programming to answer in a programming forum, which is not correct. It's not a programming question, and in my opinion, the most valid answer would be to instruct to the OP that his/her question structure does not agree with the subject matter of this forum and that the question should be either rephrased to fit the subject matter or directed to another location. Something I feel confident Quzah would have said had he responded to this thread before anyone else.

    While there is no obligation, there certainly is an expectation to respect the environment of the forum and to both ask and answer questions with full regards to that environment. This is to ensure that the subjects presented don't confuse people who are not as familiar with the subject or subjects presented as you or Quzah certainly are. Try and tell me that if this thread went on answering the question with respects to number systems rather than programming that some first level CS student wouldn't think that perhaps a significant amount of modern computers might store floating point data in that format.

    By the way... I find it tremendously insulting for people to suggest that Quzah or anyone that has been on this forum as long a him could read 1100110.11 and wouldn't comprehend what is being implied by the OP. You don't need "formal education in number systems" to know what is being said there... but the very fact that you're talking about number systems in a C forum is exactly what I, and Quzah, and a few others have an issue with.
    Sent from my iPad®

  15. #45
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    Quote Originally Posted by Mario F. View Post
    Not overly excited by seeing a floating point sign in a binary representation myself. I'd rather preferred if the OP teacher had explained to him the IEEE 754 binary representation and he was now asking us about such a datum.
    And how is our student going to get through learning about IEEE754 without dealing with a floating point sign in a binary representation? That's what the mantissa of a IEEE754 float is, after all. (EDIT: What am I saying? The mantissa is fixed point. Still has a (binary/radix) point, though.)
    Last edited by tabstop; 02-01-2011 at 05:11 PM.

Page 3 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