Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prettyprint is changing my decimals #83

Open
jonolds opened this issue Nov 3, 2024 · 5 comments
Open

prettyprint is changing my decimals #83

jonolds opened this issue Nov 3, 2024 · 5 comments
Labels
bug Something isn't working probably fixed? the issue/feature appears to be fixed/implemented, but there still may be issues

Comments

@jonolds
Copy link

jonolds commented Nov 3, 2024

For example, I'll copy and paste in:

[{"idx":0,"start":0.0,"end":1073.11,"duration":1073.11,"frameDetails":{"start_frame":430,"end_frame":46215,"start_pts":440320,"end_pts":47324160,"start_pts_time":9.98458,"end_pts_time":1073.11}},{"idx":1,"start":2143.89,"end":2175.41,"duration":31.5114,"frameDetails":{"start_frame":92760,"end_frame":93686,"start_pts":94986240,"end_pts":95934464,"start_pts_time":2153.88,"end_pts_time":2175.38}},{"idx":2,"start":2254.69,"end":2317.25,"duration":62.5537,"frameDetails":{"start_frame":97532,"end_frame":99795,"start_pts":99872768,"end_pts":102190080,"start_pts_time":2264.69,"end_pts_time":2317.24}}]

and I'll hit pretty print and get:

[ { "idx": 0, "start": 0.0, "end": 1073.1099999999999, "duration": 1073.1099999999999, "frameDetails": { "start_frame": 430, "end_frame": 46215, "start_pts": 440320, "end_pts": 47324160, "start_pts_time": 9.9845799999999993, "end_pts_time": 1073.1099999999999 } }, { "idx": 1, "start": 2143.8899999999999, "end": 2175.4099999999999, "duration": 31.511399999999998, "frameDetails": { "start_frame": 92760, "end_frame": 93686, "start_pts": 94986240, "end_pts": 95934464, "start_pts_time": 2153.8800000000001, "end_pts_time": 2175.3800000000001 } }, { "idx": 2, "start": 2254.6900000000001, "end": 2317.25, "duration": 62.553699999999999, "frameDetails": { "start_frame": 97532, "end_frame": 99795, "start_pts": 99872768, "end_pts": 102190080, "start_pts_time": 2264.6900000000001, "end_pts_time": 2317.2399999999998 } } ]

What did you do with my 1/1000000000000?! j/k, I love your plugin. This is the first beef I've ever had over years of use, and I will not be shocked at all if it's something I messed up. Thank you!

@molsonkiko
Copy link
Owner

@jonolds

This is effectively a duplicate of #81, which I foolishly closed because at the time I didn't feel like dealing with this issue even though it's obviously unacceptable.

I'm in the process of working on a fix, and I hope to have it solved by the end of the day.

molsonkiko added a commit that referenced this issue Nov 3, 2024
Need to know speed of parsing and dumping before re-implementation
to fix bug where numbers like 11.11 lose precision unnecessarily
due to stupidity of G17 formatting of numbers in C#.
See issues #81, #83.
@molsonkiko
Copy link
Owner

This commit should address this issue. If you follow my instructions for downloading an unreleased version, you can test out this fix and see if it is too your liking.

As I noted in the changelog, this fix comes at the cost of noticeably worse performance when reformatting very large files (say, several megabytes or more). I wish I could think of a way to do this with less of a hit to performance, but I don't think I'm a competent enough programmer to implement a performant and correct double-formatting algorithm from scratch.

Please let me know if you have any thoughts. If you are satisfied with this fix, I will be including it in v8.2 of JsonTools, which I aim to release in the next few weeks.

@jonolds
Copy link
Author

jonolds commented Nov 4, 2024

Awesome, I'll give it a try tonight. thank you so much!

@molsonkiko molsonkiko added probably fixed? the issue/feature appears to be fixed/implemented, but there still may be issues bug Something isn't working labels Nov 5, 2024
@molsonkiko
Copy link
Owner

JsonTools version 8.2, incorporating a fix for this issue, is now live. I will soon submit a PR to include v8.2 in the plugins manager.

@Souldrinker
Copy link

Hmm, are you sure the issue is fixed in 8.2? I noticed on a colleagues computer that when he pretty printed the same JSON file as me the output looked different. Turned out I had an ancient version (4.4) and for me this json attribute:
"RealPlannedHours":0.10
...got converted into 0.1 but 0.10000000000000001 on his (with 8.1).

I updated through the npp plugin admin to the latest available 8.1 version and then I got the same.

Then I found this repo and downloaded the 8.2 x64 release and replaced the plugin in the plugin folder (plugin admin now shows 8.2) and still I get the same incorrect response as with 8.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working probably fixed? the issue/feature appears to be fixed/implemented, but there still may be issues
Projects
None yet
Development

No branches or pull requests

3 participants