Originally Posted by
Kleid-0
But quzah master5001 is not talking about the compiler, I believe. So it doesn't matter if they're integers or not, he's talking about the processor itself and how it comes up with 0.5, and THEN the compiler makes it 0 because it has to be an integer..? I've been trying to follow along here, so let's proceed! Wait nevermind I reread CornedBee's post.
"performed by the integer unit of the CPU" --CornedBee
It seems we have a winner here.
I nor did I at any point say my cpu would perform this calculation. I said that the when dividing the size of a pointer to a double (which on my machine--for prelude's sake NOT my compiler--is 4 bytes) by the size of a double (8 bytes on my machine) is *drum role* 0.5. I will repeat myself one last time since some of you have selective reading patterns.
The following code:
Example:
Code:
size_t TheOnePartWeAllSeemToAgreeOn(double *array) {
return sizeof(array)/sizeof(double);
}
int main(void) {
double array[0x100];
printf("The one undisputable part of this whole ****ing debate: %d",
TheOnePartWeAllSeemToAgreeOn(array));
return 0;
}
Will print the following:
Code:
The one undisputable part of this whole ****ing debate: 0
Why? Because integer math truncates decimals. Where are you all getting lost? I HAVE NO IDEA! Apparently other than using a calculator that only does integer math many of you clearly seem to lack the ability to perform simple division in your heads. It amazes me how oblivious you guys are. Profound. I'm not going to post on this anymore because its become pointless.
Between some of you basically ignoring details that have been said (which is frustrating) and one of you not knowing the difference between a computer, a compiler and mental math (amusing), this has become like watching the Three Stooges put together a car.
[edit]
>result in an integer answer.
>When you have floating point numbers the processor gets a >different instructions that tell it to do floating point division.
>So at no point in time does 4/8 = .5 in the processor.
Interesting, so your brain is only capable of dividing through the div command? I appologize for flaming you earlier Thantos, it turns out you aren't a slightly clueless human afterall. Instead you are a highly advanced android.
[/edit]