I have a file that stores 7 numbers in double. See below. But its size is only 34 bytes. Shouldn’t it be 7*8 = 56 bytes instead?
$ cat data 17.2 18.1 16.5 18.3 12.6 0.75 0.25$ ls -l data -rw-r--r-- 1 root root 34 Apr 15 03:29 data
Advertisement
Answer
The file contains text representations of the numbers (e.g. written out as digits with a decimal point and a newline separator) rather than as IEEE-754 floating point numbers. The byte count you’re seeing is for the number of characters used, not the number of bytes needed in IEEE-754 format.