GithubHelp home page GithubHelp logo

conversion of unit to string about units HOT 3 CLOSED

llnl avatar llnl commented on August 28, 2024
conversion of unit to string

from units.

Comments (3)

phlptp avatar phlptp commented on August 28, 2024

The original conversion is lost, there is no way to store the original string in a very compact data structure. So generally the to string operations convert to the most compact representation. Still some bugs I am sure, but the general requirement was that the string produced needed to be able be converted back into the same unit.

A Bq is a count/sec usually used in counting radioactivity so technically correct but obviously not what you might be looking for.

so options would include

units::precise_unit samples=generate_custom_count_unit(3);
addUserDefinedUnit("samples",samples);

Then it would never get mistaken for a count. and the string would produce
"samples/s" Though if you really wanted samples/second at that point

addUserDefinedUnit("samples/second", samples/precise::s);

Side Note: still need to generate more documentation on generating custom_units and custom_count_units.

from units.

phlptp avatar phlptp commented on August 28, 2024

As for Hz Kind of an interesting discussion I suppose. On the systems I interact with it would be more appropriate to have Hz be defined at 2*pi*rad/s but then the relationship of second==Hz.inv() wouldn't work. Though there are routines in the convert methods that deal with conversions between radians, count, and moles.

As far as counting of specific things I have either used a custom_count_unit or use the commodity field of the precise_unit type to keep track of what it is. Though based on your comment I might want to revisit the use of Bequerel in the case of count/s for string output, maybe I should just take that out of the string output as it seems to be more of niche unit and could be confusing in other fields.

from units.

phlptp avatar phlptp commented on August 28, 2024

added documentation
and removed Bq from the unit to string conversion since that is an uncommon unit and often was confusing.

from units.

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.