Commit Graph
228 Commits
Author SHA1 Message Date
Mateusz Pusz 159e2c1c02 ratio_text improved to omit den == 1 for exp != 0 2019-12-29 17:19:55 +01:00
Mateusz Pusz 09e118380c Electronvolt and dalton support added 2019-12-28 19:22:57 +01:00
Mateusz Pusz 69dcfd2e6d Bitrate UDLs fixed 2019-12-28 19:00:19 +01:00
Mateusz Pusz 17e6b0d75d Small refactoring of new ratio (resolves #14) 2019-12-28 18:59:53 +01:00
Oliver Schönrock 23d44c1b4a implementing our own (very limited) std::pow functions
integer and float treated separately
perhaps not ideal, but not obvioius what would be clearly better
2019-12-28 17:59:47 +01:00
Oliver Schönrock 0ad78fe753 small changes based on code review 2019-12-28 17:59:47 +01:00
Oliver Schönrock 509b6c9653 implementing ratio<num,den,exp> which replaces ratio<num,den>
https://github.com/mpusz/units/issues/14

This "works", as in it passes all static and runtime tests.
However quite a few of the tests have been "modified" to make them pass. Whether
this is legitimate is debatable and should be the source of some thought /
discussion.

1. many of the static tests and some of the runtime tests have had the input
ratios of the tests modified in the following way. eg ratio<3,1000> =>
ratio<3,1,-3>. ie they have been "canonicalised".

There are obviously an infinite number of ratios which represent the same
rational number. The way `ratio` is implemented it always moves as "many powers
of 10" from the `num` and `den` into the `exp` and that makes the `canonical`
ratio.

Because these are all "types" and the lib uses is_same all over the place, only
exact matches will be `is_same`. ie ratio<300,4,0> !is_same ratio<3,4,2> (the
latter is the canonical ratio). This is perhaps fine for tests in the devlopment
phase, but there may be a need for "more forgiving" comparison / concept of
value equality. One such comparison which compares den,num,exp after
canonicalisation is the constexpr function `same` as defined at top of
`ratio_test.cpp`. We may need to expose this and perhaps add even more soft
comparisions.

2. In the runtime tests it is "subjective" how some resukts should be
printed. There is the question of "how exactly to format certain ratios". eg
omit denominators of "1" and exponents of "0". However before even addressing
these in detail a decision needs to be made about the general form of
"non-floating-point-converted" ratios which do not map exactly to a "Symbol
prefix".

Arguably these are "relatively ugly" whatever we do, so we could just
go for an easily canonicalised form. An example is:

-        CHECK(stream.str() == "10 [1/60]W");
+        CHECK(stream.str() == "10 [1/6 x 10⁻¹]W");

Which of thses is "better"? Is there a "third", better form?  It's not obvious.

My opnion is: Both of 1&2 are fine for now, unless we think they go down the
wrong avenue, and can be "perfected later"? ie we can expose a softer version of
ratio based equality, and decide on canonical way of printing ratios (as far as
that is actually a very useful output form, compared with decimal, scientific or
engineering notation).
2019-12-28 17:59:47 +01:00
Mateusz Pusz eef6371ab4 Missing fixed_string comparison operators added 2019-12-26 14:03:55 +01:00
Mateusz Pusz bf5762dbbb Initial support for printing multiple negative exponents added 2019-12-26 12:07:08 +01:00
Mateusz Pusz 83516346e7 tonne definition fixed 2019-12-26 12:06:12 +01:00
Mateusz Pusz 594f92241a tonne added 2019-12-26 10:27:20 +01:00
Mateusz Pusz 2a7f2efa15 hectometre and hectare added 2019-12-26 10:20:30 +01:00
Mateusz Pusz 70fbf300b4 astronomical unit added 2019-12-26 10:11:12 +01:00
Mateusz Pusz 15e148381d decimetre and litre added 2019-12-26 10:07:02 +01:00
Mateusz Pusz 22fabb5a1b day unit added 2019-12-26 09:59:05 +01:00
Mateusz Pusz 7cad312b55 fixed_string refactored 2019-12-23 13:21:48 +01:00
Mateusz Pusz e622ecb35a Warning and other compilation flags cleanup 2019-12-23 13:19:34 +01:00
Mateusz Pusz 2ab233610f physical::DimensionOf concept updated 2019-12-17 22:27:15 +01:00
Mateusz Pusz bc8c31caa5 is_derived_from_instantiation fixed 2019-12-17 22:18:52 +01:00
Mateusz Pusz 589e26fa81 no_prefix set for prefixed_unit 2019-12-17 20:16:05 +01:00
Mateusz Pusz 3decaecb52 TODO comments clean-up 2019-12-17 20:15:38 +01:00
Mateusz Pusz 80a13b1a94 US system isolated from SI 2019-12-17 12:29:19 +01:00
Mateusz Pusz d5f7de8ecb unknown_dimension definition changed to contain at least one exponent 2019-12-17 08:36:31 +01:00
Mateusz Pusz 00d863508d base_dimension refactored
- now stores dimension's symbol rather than its name
- temperature and current renamed to exactly match their names in SI
2019-12-16 15:58:41 +01:00
Mateusz Pusz 6596c15238 scaled_unit template parameters order fixed (sorry Oliver) 2019-12-14 21:16:15 +01:00
Mateusz Pusz 5ef0bb9a9f base_dimension more constrained and comparison fixed 2019-12-14 21:12:17 +01:00
Mateusz Pusz 8d1eb4c415 derived_dimension code split to a few smaller files 2019-12-14 12:23:47 +01:00
Mateusz Pusz b1b63e1b3a 2 parital specializations of a derived_dimension split to different types 2019-12-14 11:44:56 +01:00
Mateusz Pusz e10f5baab6 Quantity cast for dimension now uses dimension's coherent unit 2019-12-12 15:38:21 +01:00
Mateusz Pusz fbf3ef8c4f Most of concepts moved to a new file + quantity.h split to smaller pieces 2019-12-12 13:17:31 +01:00
Mateusz Pusz 9d50ea6ab5 CGS case added to avg_speed example 2019-12-11 21:38:44 +01:00
Mateusz Pusz 73033e347a exbi data prefix added (resolves #37) 2019-12-11 17:41:18 +01:00
Mateusz Pusz 12b67923bc CGS tests added 2019-12-11 16:20:08 +01:00
Mateusz Pusz 71f38222ea Implicit conversions fixed 2019-12-11 16:16:05 +01:00
Mateusz Pusz 5a7324596d Resulting unit ratio fixed in arithmetic operations 2019-12-11 13:31:40 +01:00
Mateusz Pusz c3c80fde11 Spaceship support added (resolves #19) 2019-12-11 11:27:51 +01:00
Mateusz Pusz e472fdc348 Most of the operators converted to hidden friends 2019-12-11 10:44:55 +01:00
Mateusz Pusz 4f769982a5 TODO removed 2019-12-11 09:32:29 +01:00
Mateusz Pusz c1e4e57d84 clang-format + TODOs added to ratio 2019-12-11 09:28:40 +01:00
Mateusz Pusz 4304747406 -pedantic warning flag reenabled 2019-12-11 09:27:17 +01:00
Mateusz Pusz 9bebf316a7 gcc-9.1 build fixed 2019-12-11 08:27:12 +01:00
Mateusz Pusz 9e34050e23 fmt and catch2 updated to the latest versions 2019-12-11 08:22:12 +01:00
Mateusz Pusz bc1901f4f0 Text formatting enabled + directory tree refactoring 2019-12-11 08:07:13 +01:00
Mateusz Pusz 8ffc46ba75 CGS support added 2019-12-09 17:19:58 +01:00
Mateusz Pusz 7619a6f831 gcc-10 crash fixed 2019-12-08 21:57:06 +01:00
Mateusz Pusz 6b4220100f quantity_cast refactored
- new version with ToD added
- <ToU, Rep> version removed
2019-12-08 16:24:29 +01:00
Mateusz Pusz d465d47803 range-v3 dependency removed for gcc-10 2019-12-08 16:09:00 +01:00
Mateusz Pusz 2c29af9670 Custom unit and data tests enabled 2019-12-07 18:33:55 +01:00
Mateusz Pusz 22eda11bea More refactoring
- unknown_unit and unknown_dimension added
- the support for remaining SI units added
2019-12-07 16:30:40 +01:00
Mateusz Pusz 33f14f39f3 math_test enabled 2019-12-06 12:56:44 +01:00