libimobiledevice / libplist

A library to handle Apple Property List format in binary or XML
https://libimobiledevice.org
GNU Lesser General Public License v2.1
544 stars 305 forks source link

Loss of precision when parsing or writing real values #146

Closed dnicolson closed 4 years ago

dnicolson commented 4 years ago

Values of type real can lose precision if they contain more than 6 decimal places. After using the plist_test binary, the value 8263.0072447640268 becomes 8263.007245 and the value 0.0 becomes 0.000000.

The following commands:

git clone git@github.com:libimobiledevice/libplist.git
cd libplist
git checkout 072a31
./autogen.sh
make
cd test
./plist_test ~/precision-real.plist ~/precision-real-2.plist

Give the following output:

File /Users/dave/precision-real.plist is open
PList XML parsing succeeded
PList BIN writing succeeded
PList BIN parsing succeeded
PList XML writing succeeded
Size of input and output is different
Input size : 1155
Output size : 1139

precision-real.plist.zip

nikias commented 4 years ago

Please check b7c802f1b7cdf8a271b148d4375c4309aefc5e0d. The input and output size will probably still differ, but it now handles 0.0 and the others cases like the official plutil tool.

dnicolson commented 4 years ago

This works correctly now and the output size is the same. The attached plist had some whitespace inconsistencies, running it through plutil twice and then plist_test produced the same file size.