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

Decimal number displayed differently #108

Closed
Duologic opened this issue May 5, 2023 · 5 comments
Closed

Decimal number displayed differently #108

Duologic opened this issue May 5, 2023 · 5 comments
Assignees
Labels
wontfix This will not be worked on

Comments

@Duologic
Copy link

Duologic commented May 5, 2023

Just a difference I found but this time I actually like this change but it does make it harder to switch back/forth between versions. Perhaps this is something that needs fixing in the go version? 🤷

➜ jsonnet -e 0.97
0.96999999999999997

➜ jrsonnet -e 0.97
0.97
@CertainLach
Copy link
Owner

❯ nix run nixpkgs#go-jsonnet -- -e "std.manifestJson(0.97)"
"0.97"
❯ nix run nixpkgs#go-jsonnet -- -e "std.toString(0.97)"
"0.96999999999999997"
❯ nix run nixpkgs#go-jsonnet -- -e 0.97
0.96999999999999997

❯ nix run nixpkgs#jsonnet -- -e "std.manifestJson(0.97)"
"0.96999999999999997"
❯ nix run nixpkgs#jsonnet -- -e "std.toString(0.97)"
"0.96999999999999997"
❯ nix run nixpkgs#jsonnet -- -e 0.97
0.96999999999999997

❯ cargo run -- -e "std.manifestJson(0.97)"
"0.97"
❯ cargo run -- -e "std.toString(0.97)"
"0.97"
❯ cargo run -- -e 0.97
0.97

Well... It looks like an inconsistency, but I wonder how/should it be fixed in jrsonnet?
In jrsonnet, -e output is serialized in the same way as std.manifestJson does.

@Duologic
Copy link
Author

Duologic commented May 7, 2023

This turns out to be more interesting than I expected, @sparkprime wdyt?

@Duologic
Copy link
Author

Duologic commented May 12, 2023

FYI, I've brought this up on the #jsonnet Slack channel on Kubernetes public Slack, Dave found more inconsistencies.

@sparkprime
Copy link

My preference would be for the shortest exact string. There was no way to do that in C++ and we matched that behaviour in Go. Given we're trying to move people off of C++ to Go it may be a good time to switch Go over to the shorter output.

@Duologic
Copy link
Author

Duologic commented Aug 3, 2023

I've made an upstream issue (google/go-jsonnet#718), I think it should be fixed there, closing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

3 participants