Git Product home page Git Product logo

Comments (2)

thehans avatar thehans commented on May 7, 2024

I guess another alternative to having ToShortest somehow take in requested digits, would be to have another flag for ToPrecision. Something like TRIM_SIGNIFICANT_ZEROES_AFTER_POINT

So that tests like this could pass when added to TEST(DoubleToPrecision)

  builder.Reset();
  CHECK(dc8.ToPrecision(2000, 6, &builder));
  CHECK_EQ("2000", builder.Finalize());

  builder.Reset();
  CHECK(dc8.ToPrecision(2000.001, 6, &builder));
  CHECK_EQ("2000", builder.Finalize());

So even though I requested 6 digits, if its nothing but zeroes after the point I would rather they be trimmed away. I guess I initially expected that not setting either of EMIT_TRAILING_DECIMAL_POINT
or EMIT_TRAILING_ZERO_AFTER_POINT would behave in this way, but now I understand those only matter if the decimal point occurs after the requested digits.

from double-conversion.

floitsch avatar floitsch commented on May 7, 2024

I can see your point, but I don't think this functionality is used often enough to add it to the library. (Especially, because it's quite easy to just fix the output after the fact).

I'm quite busy these days, so I rather just close this issue, instead of giving the hope that it might happen anytime soon.

from double-conversion.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.