Ok. i will try not to be nasty here:
#1. $testdata = "345657";
will cast $testdata = string data.
u can go "type bar.bin" in DOS and see the numbers exactly as 345657. Dun take my word for it. see for urself.
Thus this $testdata dun stand valid for numeric binary testing. the rest of the testing is rendered useless as well.
#2. IF you use $testdata = 345657;
i.e. in binary representation it would be 0x054639 or (at least) 3 bytes (4 bytes for long int) of binary value.
each of them in their byte representation would be (if u read off 1 by 1)
0x05 =
0x46 = ,
0x39 = '
at 1st glance, none of them look number (ascii). and surely after u fread() them, even if u shld (int)-cast them, they are garbage and will be 0-cast instead. Adding them returns 0 nonetheless.
Jem
Hope u have fun finding out the truth.