PBD_ctrl Posted December 18, 2013 Report Posted December 18, 2013 This is my first post but I have been browsing LAVA for years! I couldn't figure out how to post this within the repository forums so I decided to throw it up here. I am using the JSON LabVIEW 1.1 API in a large project and just came across an issue. The attached VI shows the problem but what it boils down to is that doubles get truncated to 6 decimal places. It is being truncated because of the Format Into String function's "format string". Was this done on purpose? I know how to make the change that I am looking for but I would like to see it get worked into the package's source. Thanks, -Pat Build Basic JSON.vi Quote
drjdpowell Posted December 18, 2013 Report Posted December 18, 2013 For lack of a better reason I just used the default. More digits would be better for precision, but worse for compactness. Perhaps we could make the format string an optional input? Quote
PBD_ctrl Posted December 19, 2013 Author Report Posted December 19, 2013 A format string would help but what about the set variant VI? Quote
drjdpowell Posted December 19, 2013 Report Posted December 19, 2013 The set variant VI would need the same input, either "numeric format" or "numeric precision". 1 Quote
drjdpowell Posted December 20, 2013 Report Posted December 20, 2013 Googling other JSON implementations, I think we should change the format to the following: SGL: %#.6g (equivalent to the %#g we have now) DBL: %#.14g EXT: as many digits as the LabVIEW functions to make text from numbers give us, which seems to be only %#.17g from my limited testing This is deliberately less than maximum precision, so as not displaying decimal numbers like 0.1 as 0.10000000000000001. Quote
drjdpowell Posted December 20, 2013 Report Posted December 20, 2013 (edited) Mixed up precision and significant figures. Now proposing: SGL: %#_7g (seven figures) DBL: %#_15g EXT: ?!? (I can't seem to get more significant figures for EXT than for DBL using the format as text functions). Edited December 20, 2013 by drjdpowell Quote
drjdpowell Posted December 20, 2013 Report Posted December 20, 2013 Here's an updated JSON package. Please give it a try. lava_lib_json_api-1.1.2.19.vip 1 Quote
PBD_ctrl Posted December 23, 2013 Author Report Posted December 23, 2013 Looks good to me! Thanks for the change. Are you considering getting this onto the LV Tools Network? Quote
mje Posted December 24, 2013 Report Posted December 24, 2013 If LabVIEW limits the string representation of EXT numbers you may be able to extract more digits by rounding to some precision, generating the first set of digits, then generating the second group based off the difference. Ugly for sure, but if that's the only way... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.