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; Originally Posted by brewbuck Yes, and the original question was just a fixed-point question. The value 1100110.11 is just a ...

  1. #61
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,412
    Quote Originally Posted by brewbuck View Post
    Yes, and the original question was just a fixed-point question. The value 1100110.11 is just a Q2 fixed point value. We write down the dot to remember what the Q is. Nobody ever suggested that somewhere inside the computer there is a "dot" flying around.
    Q7.2, even.

    Very well, from here on I'll assume the OP was being taught how to represent numbers on systems without an FPU, and as such I'm wrong when I criticized his teacher for having shown him an inadequate representation of a modern computer.
    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.

  2. #62
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,831
    Quote Originally Posted by SlyMaelstrom View Post
    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.
    You can find it insulting on behalf of quzah if you like.

    According to quzah: "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."

    So quzah himself states that he has no trouble interpreting the OP's question as being in base 10 to begin with. This, presumably, to try to save face in a losing argument. [flame war alert!]

    I really don't see a problem if someone has not had exposure to a binary point representation of numbers. His assertion that it doesn't exist is simply wrong on that basis.

    Binary point is not something supported by library functions scanf, or atoi if they include native base 2 at all. Base 10, 16, 8 only (%d, %x, %o). And then only for integers. There is no binary support except the suffix 'b' for constants I believe. Maybe some compilers only.

  3. #63
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,670
    Of course...10 is the only *real* number base (in fact, all bases require as many digits, don't they?). The base-10 point is almost superfluous...
    Last edited by Sebastiani; 02-03-2011 at 02:16 PM. Reason: ...



    ITSA
    Socket Library!

  4. #64
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by nonoob View Post
    You can find it insulting on behalf of quzah if you like.

    According to quzah: "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."

    So quzah himself states that he has no trouble interpreting the OP's question as being in base 10 to begin with. This, presumably, to try to save face in a losing argument. [flame war alert!]

    I really don't see a problem if someone has not had exposure to a binary point representation of numbers. His assertion that it doesn't exist is simply wrong on that basis.

    Binary point is not something supported by library functions scanf, or atoi if they include native base 2 at all. Base 10, 16, 8 only (%d, %x, %o). And then only for integers. There is no binary support except the suffix 'b' for constants I believe. Maybe some compilers only.
    I wasn't trying to save face, because I don't care if I'm wrong here. I'm fine that people use decimals in binary. I don't, but you can if you want to. It doesn't affect me.

    I was just being pedantic. You cannot look at any arbitrary number and know what base it is. You just can't. You can't know if I mean "10" as ten or as binary, or as something else entirely in hex. We all assume that "10" is ten, because that's the base we normally use. But without them telling use what base it is, you cannot do anything more than guess. I don't care if I win whatever we're arguing about now. I'm just being pedantic - you cannot know what base he actually meant, because he didn't say what he actually meant.


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

  5. #65
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,620
    Quote Originally Posted by Sebastiani View Post
    Of course...10 is the only *real* number base (in fact, all bases require as many digits, don't they?). The base-10 point is almost superfluous...
    Every base can be expressed everyway we like it to. Take hexadecimal for example:

    The typical and widespread representation is: 0123456789ABCDEF

    What if we used dots for every digit: 4D42 <==> 4.13.4.2

    There's no actual limit. The limit is in our minds and our way of thinking, model, or beliefs
    Devoted my life to programming...

  6. #66
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Location
    Plano, Texas, United States
    Posts
    2,738
    Quote Originally Posted by quzah View Post
    I wasn't trying to save face, because I don't care if I'm wrong here. I'm fine that people use decimals in binary. I don't, but you can if you want to. It doesn't affect me.

    I was just being pedantic. You cannot look at any arbitrary number and know what base it is. You just can't. You can't know if I mean "10" as ten or as binary, or as something else entirely in hex. We all assume that "10" is ten, because that's the base we normally use. But without them telling use what base it is, you cannot do anything more than guess. I don't care if I win whatever we're arguing about now. I'm just being pedantic - you cannot know what base he actually meant, because he didn't say what he actually meant.
    I'm surprised this entire argument has even happened.

    First of all, despite the fact that "10" could represent a number in essentially any base, I think it's quite easy to derive from the context of the OP's post that he was clearly wanting convert a base 2 number to a base 10 number. We're all about context here, people. Be sensible, and use it.

    Second, it's also clear that any number base can represent fractions, whether it be base 2 (binary), base 3, base 10, base 11, base 26, or base 2024236. Just because we don't normally write fractions using base 2 the same way as we do base 10 doesn't mean it is an incorrect way to do it.
    My Website

    "Circular logic is good because it is."

  7. #67
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quote Originally Posted by Sipher View Post
    There's no actual limit. The limit is in our minds and our way of thinking, model, or beliefs
    Of course there is no absolute relation between the way a number is notated and what the that number represents. But, there are established conventions, break those, and communication breaks down as well.

  8. #68
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,620
    Quote Originally Posted by Subsonics View Post
    Of course there is no absolute relation between the way a number is notated and what the that number represents. But, there are established conventions, break those, and communication breaks down as well.
    I understand and totally agree with that, just like ASCII, just like any programming language! For example, it's difficult porting from Microsoft compilers to those of GNU because they have different syntax in some areas. Communication has broken down between those compilers, although there're tricks to get past them, the established and universal preprocessor! etc, etc, etc...

    Devoted my life to programming...

  9. #69
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Quote Originally Posted by Subsonics View Post
    Of course there is no absolute relation between the way a number is notated and what the that number represents. But, there are established conventions, break those, and communication breaks down as well.
    You cannot argue this in the context of this thread, and allow for decimals in binary numbers. This thread appeared on the C board, which sets the context and the "established conventions". You never have a decimal place when you manipulate binary numbers in C - because it would be stupid and backwards to do so. The input would have been a string, and you would be converting from a string to a given base - in this case, base 10.

    Since there are never decimal points when working with binary (bit manipulation, because you can't manipulate the bits of a floating point number directly) this number automatically defaults to being a string of base-10 numbers, in the provided context.

    You cannot argue for following conventions, and have that be anything other than a base 10 number, in the context it was provided. Either your argument is wrong, or the context provided was wrong. You can't have both be right in this thread. (Yes, I'm just arguing for the sake of arguing now.)

    You can't say "you only get one decimal point" (which is what you're saying), and at the same time say "yes there must be one decimal point for binary numbers", in the context it was provided (being on the C board), because nothing you ever do with binary numbers in C uses a decimal point.


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

  10. #70
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,412
    Quote Originally Posted by quzah View Post
    because nothing you ever do with binary numbers in C uses a decimal point.
    Well, here I disagree, quzah. Been pretty much in agreement with you so far, but here I think you are being too intransigent. So far I've looked at this thread as some schoolboy assignment whose teacher asked him to convert a binary notation that uses a decimal point. And I completely agree this is not the correct way of teaching the handling of real numbers by modern computers. In fact, it's completely obtuse and will serve no purpose as a teaching tool.

    However the notation itself exists. And can be instrumental on certain very specific cases where C is being used. And even in a direct relationship to how these numbers are stored. This is the case of systems where there's no FPU. Here, you bet it will be common practice for numbers to be represented in the Qm.f notation. They aren't stored exactly this way, but are used in this way by C. Naturally the decimal point doesn't exist. But its representation is fundamental in any specs literature about these systems, or in code comments.

    Now, you and I both know this isn't the case. My last post on this thread was basically in jest. I simply know for a fact the OP wasn't being taught about systems without an FPU because if he were, the enunciate of the problem would be telling him the actual notation used. And he would be telling us that too in his question. The only possible real answer to the initial question is "What's the notation used?". We can't convert this number from Qm.f, because the actual notation could be fxm.b (*), or something else entirely. Some here assumed something akin to a decimal representation. But we simply don't know what's the notation of that representation.

    Because he didn't tell us anything of that, we know for a fact this isn't about systems without an FPU. So it's safe to say that's a wrong representation for decimal numbers and it should be banished. But make no mistake you need that notation, and you'll use it when talking about (not coding) systems without an FPU.

    ...

    (*) before anyone complains... yes, you can have 9-bit boundaries.
    Last edited by Mario F.; 02-05-2011 at 03:11 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.

  11. #71
    Registered User
    Join Date
    Jan 2009
    Posts
    1,485
    Quazah,

    I'm only emphasising what Sipher said, that the relation between a sign and what is signified, is arbitrary. Then I go on to say that eventhough it's arbitrary, it's not up to individuals to make up their own, but to use established conventions. That's it. I haven't ever seen a decimal point in a binary number myself, and I'm not arguing for it's use.

  12. #72
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Well since we've never heard from the OP again, and since it's been moved, and since everyone's tired of pointless debate... I'm off to make a sammich!


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

  13. #73
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,163
    It really doesn't make a lick of difference how C handles bit manipulation. The OP obviously was simply asking how to write a base2 to base10 converter. It could have just as easily been how to convert fahrenheit to celcius. Would you argue that it's impossible and doesn't make sense because C doesn't know how to handle temperatures? No, the temperature, just like the base2 number the OP is trying to convert, is just an abstract entity contained in a string and you can treat it however you want, regardless of C's internal limitations.
    If you understand what you're doing, you're not learning anything.

  14. #74
    Programming Wraith GReaper's Avatar
    Join Date
    Apr 2009
    Location
    Greece
    Posts
    1,620
    From what i've read here, the real problem is that not everyone have the same opinion about what a number is! Since we can't force someone to believe what we do, lets end it here, please. ( Quoting quzah )
    Devoted my life to programming...

  15. #75
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Portugal
    Posts
    7,412
    III.MCDXV
    or even,
    X.XXMCDXV

    My gift for all you notation liberals in here. And please, don't pay attention to anyone who tries to tell you there should be some means of formal communication between programmers. We all know that is nonsense. Communication is overrated.
    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.

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