For me, the following code
fid = fopen('test.dat','wt');x = single(1.28);fwrite(fid,x,'single');bytes = ftell(fid)
produces the result
bytes = 5
instead of the expected result
bytes = 4
which I get for most other values of x. The value of 1.28 is one example, but not an isolated case. In general, about 1 to 2 percent of values take 5 bytes instead of 4. For example,
fid = fopen('test.dat','wt');x = single(rand(10000,1));fwrite(fid,x,'single');bytes = ftell(fid)
produces the result
bytes =
40127
Does anyone know what is going on here and why?
Best Answer