Comments (5)
This is probably the best place to write this down right now (we should create a new github repository for that).
One thing we haven't considered during Liaw is potential support for currencies. They are an interesting use case because they only require limited precision, but well defined rounding, and their conversion factors can change during runtime.
from units.
from units.
We already don't have a scaling factor that is a power of ten (Imperial units and the conversion from/to SI) in every case. Once you try to deal with natural units, you also have irrational numbers, which should not be approximated with std::ratio
, because you will overflow the integer pair once you try to do math with them.
(This is assessed by the numeric TS free functions.)
I have found P0105R0 which addresses rounding. It says:
The unmotivated modes all_away_zero [...] are conditionally supported.
Which is AFAIK the rounding mode used to convert from the national currencies to the Euro (I don't write financial software, but there does not seem to be a general convention/regulation regarding rounding, which surprises me).
Yes, the non constant conversion factor is the most important difference. I would just like to see a discussion if and how we could enable the user to use the conversion framework and have non-constant conversion factors with user defined types.
from units.
Hey, Peter —
I'm super interested in getting involved in the std::units
effort. Any news since 2016?
Nic, myself and Steven Watanabe have been experimenting with methods to allow arbitrary sets of dimensions to be defined and used together with the units library. See here for more details and a fork with the feature: #88
I think there are other, closely related features like vector spaces and complex analysis that relate closely to this topic and would be interesting to discuss in the context of the units library.
from units.
It'd be great if you could share more on this so that we could help.
I've been thinking on how units
could undesirable for standardization. To start with, the current design introduces its own time units, when the standard already has std::chrono::duration
. A redesign that takes it into account is in order.
There's much that needs to go if you're going to show units
as is to the committee. Reducing the scope of a proposal to some bare essentials while still maintaining its value and extensibility (program-defined units and dimensional analysis support in the case of units
) increases its chances of being accepted by removing features that potentially hold it back.
Take a look at std::chrono::duration
and back at units::length
. When was the last time you saw units::megameter_t
being used? Let's offer only commonly used aliases, like std::chrono
does.
There is value to units
' users in offering all the exotic units (as seen from all the requests #205 #181 #157 #151 #147), but not for the standard, which aims to be more generally useful and broadly applicable. One argument against is that some units' definition might might change with time, albeit insignificantly for most application, as our measuring tools improve [citation needed].
A minimal scope I've thought of is the following:
- Offer similar templates to
std::chrono::duration
per SI base quantity, likeunits::length
,units::mass
, etc. - Offer only commonly used convenient aliases to these templates, like
std::chrono
does. - Have an opt-in trait for registering these templates as base quantities. With this, the dimensional analysis functions can work out the rest.
- We'd need a generic
unit
for the non-base quantities that would result from using the dimensional analysis functions.
There are some design questions that could be directed to LEWG and SG6, as we've come a long way since the introduction of std::chrono::duration
:
- Do we hand wave the requirements for Rep or do we use concepts? I have some concepts which fit current stuff and should fit what SG6 is working on.
- With fingers crossed for https://wg21.link/P1021 being accepted, the convenient aliases could be template aliases.
The rest of units
could be proposed in sections marked as optional, so as to not intervene with the acceptance of a core proposal.
from units.
Related Issues (20)
- 2.3.2 Fails to compile HOT 2
- Conan package out of date HOT 2
- Undefined references to .name() and .abbreviation() HOT 1
- Incorrect enable_if condition for operator+ HOT 1
- Request for branch and pull request permissions HOT 5
- percent_t FROM double and TO double are different HOT 9
- 2.3.3 does not compile
- Add a way to specify units when "downcasting" to numeric type HOT 2
- Support the MSFS SDK HOT 2
- Empty base class optimization for MSVC
- Does not compile with GCC 12 HOT 1
- raw() and value() is error prone HOT 4
- [Bug] i386 (32-bit) fails to compile
- Shouldn't the naming of units::torque::foot_pound be changed
- v2 -> v3 porting HOT 2
- Need help implementing resistance as a new custom unit. HOT 2
- unit conversion emits a surprisingly high amount of instructions
- Compilation under MINGW
- Math functions not compatible with percent HOT 1
- Status of the project HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from units.