bump because kayjay and I crossed posts
Printable View
bump because kayjay and I crossed posts
1963 :o Don't think even my mother born then!Quote:
Originally posted by phinds
................anyone has any further quesitons on this subject ... fugeddaboudit !!! I'm sick of the whole thing. I first encounted this problem in about 1963 and I've explained the whole thing .............
Thanx for the time and effort. Though I still don not completely understand I'll make an effort.
phinds, take a look at this page :
http://hankfiles.pcvsconsole.com/answer.php?file=454
I dont see any round for converting 5.375
Actually the only way to test Phinds theory (which I am in agreement with) would be to do the conversion in the other direction. You will probably find that you can come up with two different binary numbers that both convert to 1.4.Quote:
Originally posted by nemaroller
These are all good explanations, but still, this code raises questions.... the binary equivalents are still equal..
[/Highlight]
Thanks for the explanation phinds .. but please dont be hard on someone for questioning 1.4<>1.4 = True :D
which is EXACTLY in agreement with my statement.Quote:
I dont see any round for converting 5.375
5.375 is rational in binary, so as I explained, it will not suffer any rounding error.
You keep setting up strawmen to avoid a conclusion that you apparently don't like.
Do the math on 1.4
If you do the math on 1.4 yes you do end up with that trailing 1100.
So then the value gets rounded. Right.
The fact remains though that you're still comparing two numbers that would have been rounded the same.
1.4 v 1.4
Well, obviously Phinds must know what he's talking about...
Its basically the fact that numbers you would think would have an absolute finite value in decimal, like .04, does not mean it is so in binary, because of the way that number system is set up... in fact, 0.4 seems to go on forever in binary when trying to convert that decimal fraction to binary... you just wont get an ending...
The same applies for 1.36..... In my limited runs, it appears only decimal fractional numbers ending with 5, can have a finite representation in binary (.375,.5,.15)
Here is an example of what's going on. I had to write the program in C to demonstrate. Check out the subtle difference when I dumped the memory where the variables were stored. Then when I print the variables again, they appear equal. In memory, however they are not. The comparison operation checks that all bits are identical. Clearly, these variables appear to hold the same value...and for math calculations it would work fine. But for comparison they are definitely not equal.
f1 = 1.360000
f2 = 0.040000
f3 = 1.400000
f1 + f2 = 1.400000
f1 dump = 0x600000003ff5c28f
f2 dump = 0x400000003fa47ae1
f3 dump = 0x600000003ff66666
f4 dump = 0x6a0000003ff66666
f1 = 1.360000
f2 = 0.040000
f3 = 1.400000
f1 + f2 = 1.400000
Here is the code I ran (for all you C buffs...it's a quick cloodge for a demo.)
Code:#include <stdio.h>
int main(void)
{
void *temp;
double f1 = 1.36f, f2 = 0.04f;
double f3 = 1.4f;
double f4;
printf("f1 = %f\n", f1);
printf("f2 = %f\n", f2);
printf("f3 = %f\n", f3);
f4 = f1 + f2;
printf("f1 + f2 = %f\n", f4);
temp = &f1;
printf("f1 dump = 0x%x%x\n", *(int*)temp, *(int*)((int)temp + 4));
temp = &f2;
printf("f2 dump = 0x%x%x\n", *(int*)temp, *(int*)((int)temp + 4));
temp = &f3;
printf("f3 dump = 0x%x%x\n", *(int*)temp, *(int*)((int)temp + 4));
temp = &f4;
printf("f4 dump = 0x%x%x\n", *(int*)temp, *(int*)((int)temp + 4));
printf("f1 = %f\n", f1);
printf("f2 = %f\n", f2);
printf("f3 = %f\n", f3);
printf("f1 + f2 = %f\n", f4);
return 0;
}
Actually, it appears only decimal fractions that are all odd and end with 5, will have a finite representation in binary....
http://www.cs.nmsu.edu/~pfeiffer/cla...otes/base.html
Hell, thats not even true.... I don't know, guess there just isn't a solid rule here....
But just to cool off this thread... the binary system was initially developed by Gottfried Wilhelm von Leibniz in 1623, but it was discovered the Chineese had actually developed it 700 years earlier.... solid lines are 1's, broken lines are 0's...
http://www.albany.net/~cybernet/Iching.jpg