Skip to content

Not getting the shortest decimal representation of 0.3 #199

Description

@ShaiWavesAudio

I ran the following code:

    char buffer[128];
    const double num = 0.30000000;
    d2fixed_buffered(num, 4, buffer);
    std::cout  << buffer << "\n";

I expected 0.3 to be printed, instead I got 0.3000, surly 0.3000 is not the shortest decimal representation of this floating point number.
What am I missing?
What is the correct way to get the shortest representation?
Thnaks,
Shai

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions