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.
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.
Of course...10 is the only *real* number base (in fact, all bases require as many digits, don't they?). :cool: The base-10 point is almost superfluous...
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.
The typical and widespread representation is: 0123456789ABCDEF
What if we used dots for every digit: 4D42 <==> 188.8.131.52
There's no actual limit. The limit is in our minds and our way of thinking, model, or beliefs
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.
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.
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.
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.
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!
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.
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 :D )
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.