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

The decimal type is not serialized #62

Open
tsadowski opened this issue Apr 26, 2023 · 3 comments
Open

The decimal type is not serialized #62

tsadowski opened this issue Apr 26, 2023 · 3 comments
Labels
bug Something isn't working PR welcome User contribution/PR is welcome

Comments

@tsadowski
Copy link

There is no toString method in TomlFormatHelper defined for the decimal floating point type. Decimal numbers are then simply missing from the output.

Reading numbers into a decimal type works.

Cheers,
Torsten

@xoofx xoofx added bug Something isn't working PR welcome User contribution/PR is welcome labels Aug 4, 2023
@lilith
Copy link
Contributor

lilith commented Feb 1, 2024

Toml (the spec) supports only binary64/double/f64 representable numbers. There's overlap between the numbers representable in binary64 and decimal, but both can express numbers that the other can't. This makes for a particularly challenging situation to implement, unless we were to use a string literal or something (which seems bad). I prototyped a solution that worked until the unit tests started testing decimal.MaxValue. It can't roundtrip, unfortunately.

lilith added a commit to lilith/Tomlyn that referenced this issue Feb 1, 2024
@lilith
Copy link
Contributor

lilith commented Feb 1, 2024

Here's my branch that explored this: https://github.com/lilith/Tomlyn/tree/decimal-support
Honestly the safest approach might be to explicitly document decimal is not supported, and also throw an exception on use.

Reading numbers into a decimal type won't work if the double is too small or large.

@xoofx
Copy link
Owner

xoofx commented Feb 1, 2024

Honestly the safest approach might be to explicitly document decimal is not supported, and also throw an exception on use.

Yep, agreed. TOML was not meant for portable data but for easy configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working PR welcome User contribution/PR is welcome
Projects
None yet
Development

No branches or pull requests

3 participants