PlistCpp icon indicating copy to clipboard operation
PlistCpp copied to clipboard

How do I set the precision at which doubles are saved?

Open ftvs opened this issue 10 years ago • 2 comments

I am saving time as seconds since epoch using doubles. For my admittedly old version of PlistCpp it saves as

    <real>1.39531e+09</real>

How do I increase its precision? Or do I have no choice but to change to longs? This would break compatibility.

ftvs avatar Mar 20 '14 09:03 ftvs

Hi,

If you can use binary plists I think it will just work as it will get written with double precision. For XML take a look at the function stringFromValue in Plist.cpp and see the accepted answer at the following stack overflow: http://stackoverflow.com/questions/12894824/double-and-stringstream-formatage for setting the precision of stringstream. Let me know how it goes.

animetrics avatar Mar 22 '14 14:03 animetrics

Thanks, I will try it out. I thought it might have exposed an interface for setting the precision that I missed, which is why I asked.

Binary happens to be too slow on the Android devices I am working on.

ftvs avatar Mar 22 '14 16:03 ftvs