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 ...
From now on a large part of your life will be spent finding and correcting your own mistakes.
And if you are lucky and land yourself a good job, a whole lot more time will be spent finding and correcting other people's mistakes.
That has to be good, no?
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.
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.
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 03:16 PM. Reason: ...
Code:#include <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
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.
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...
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.
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...
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.
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 04:11 PM.
From now on a large part of your life will be spent finding and correcting your own mistakes.
And if you are lucky and land yourself a good job, a whole lot more time will be spent finding and correcting other people's mistakes.
That has to be good, no?
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.
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.
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.
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.
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...
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.
From now on a large part of your life will be spent finding and correcting your own mistakes.
And if you are lucky and land yourself a good job, a whole lot more time will be spent finding and correcting other people's mistakes.
That has to be good, no?
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.