I use xml generated from a ValueTree structure to store plugin preset data and am currently reworking my code to deal with using the correct types again after a restore. In the process I ran into a related issue. I wrote a short routine to show the problem:
const Identifier pid("prop"); ValueTree tst("Test"); tst.setProperty(pid, 1e+40, nullptr); String xml = tst.toXmlString(); DBG(xml); XmlDocument xmlDoc(xml); ScopedPointer<XmlElement> xmlElem = xmlDoc.getDocumentElement(); auto fromXml = ValueTree::fromXml(*xmlElem); double val = fromXml[pid]; DBG(val);
On Juce tip, OSX this is the output:
JUCE v5.4.2 <?xml version="1.0" encoding="UTF-8"?> <Test prop="10000000000000000303786028427003666890752.000000"/> 1e+17
It seems serializing a double for some reason is capped at 10ˆ17. When I check the ValueTree in the debugger I see that the value is correct (double, 1e+40), but something in toXmlString() seems off.
It would be nice if toXmlString() would use the scientific format for large numbers (and small ones while we’re at it). I believe I’ve seen that in the past from JUCE, but maybe I was dreaming… or something has broken. The code can definitely parse the scientific format correctly, so this issue seems like some bug or oversight.