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

bugfix: floating point representaion without fractional part #289

Merged
merged 2 commits into from Dec 5, 2016

Conversation

jgerhards
Copy link

closes #278

@ploxiln
Copy link
Contributor

ploxiln commented Nov 28, 2016

It may be appropriate to move the which-format-string logic into a couple separate lines. Otherwise, looks good to me.

@jgerhards
Copy link
Author

I could change it if the maintainer wishes me to do so, however I don't deem it as necessary.

@hawicz
Copy link
Member

hawicz commented Dec 5, 2016

This seems like it might be a bit fragile. I would think that checking the generated output for a '.' character would be more reliable, but if this works then let's go with it.

@hawicz hawicz merged commit 1e4824a into json-c:master Dec 5, 2016
@jgerhards
Copy link
Author

as specified in man snprintf, this is guaranteed to work, see last sentence:

 g, G   The  double argument is converted in style f or e (or F or E for
              G conversions).  The precision specifies the number of  signifi‐
              cant  digits.   If the precision is missing, 6 digits are given;
              if the precision is zero, it is treated as 1.  Style e  is  used
              if  the  exponent from its conversion is less than -4 or greater
              than or equal to the precision.  Trailing zeros are removed from
              the  fractional part of the result; a decimal point appears only
              if it is followed by at least one digit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serialization of double with no fractional component drops trailing zero
3 participants