Commit Graph
110 Commits
Author SHA1 Message Date
Johel Ernesto Guerrero Peña ca1867c9b2 refactor!: pow functions as detail 2020-09-06 09:45:24 +02:00
Johel Ernesto Guerrero Peña 2f5be094b2 refactor: pow10 functions to pow.h 2020-09-06 09:45:24 +02:00
Mateusz Pusz b318e8d039 VS2019 support added 2020-09-04 23:06:57 +02:00
Mateusz Pusz 51ffbadf74 gcc-9.3 compilation fixed 2020-09-04 22:11:24 +02:00
Mateusz Pusz deb1ee6efa Truncating conversions disalowed for *=, /=, +=, amd -= operators (resolves #137) 2020-08-16 13:29:40 +02:00
Johel Ernesto Guerrero Peña 69dddaf1f6 feat: nodiscard for postfix increment and decrement 2020-08-16 12:32:56 +02:00
Mateusz Pusz d171f5451e NTTP ratio support added (resolves #49) 2020-06-27 19:15:46 +02:00
Mateusz Pusz 0c0d097586 C++20 comparison operators refactored 2020-06-19 19:37:18 +02:00
Mateusz Pusz fea072aeb5 warnings.cmake refactored 2020-05-29 10:07:01 +02:00
Mateusz Pusz 5dd9eaac87 Redundant constraints removed (resolves #109) 2020-05-24 22:49:53 +02:00
Mateusz Pusz d19825e14c Numeric concepts removed from repo (no longer used) 2020-03-28 12:08:37 +01:00
Mateusz Pusz ab1cc4b8e7 Overconstrained quantity operations relaxed 2020-03-25 15:04:33 +01:00
Mateusz Pusz c33f6f2d59 ostream width, align and fill added 2020-03-19 09:23:27 +01:00
Mateusz Pusz 1f63fdb945 Printing of a space separator for unitless quantites disabled 2020-02-24 20:01:57 +01:00
Oliver Schönrock 39a2c2de0e employing more mathemtaically correct ratio_gcd calc (for common ratio)
really finds the maximum common ration as opposed to previous algo which
simplified on the exp part of the ratio by using std::min
most of new code credit to Conor Williams
discussion and additional doc here:
https://github.com/mpusz/units/issues/62#issuecomment-588152833
test case was 1yd + 1in = 37in => added as a test
commenting out unusued ratio_add and its tests
if to be reintroduced, should also use the new gcd routines
additonal change was required to check in `safe_divisible` concept
den=1 is not sufficient anymore. reusing new gcd routines
moved ratio nomalize and new gcd routines into new, separate bits/ratio_maths.h
this resolves #62
2020-02-20 19:59:12 +01:00
Mateusz Pusz 3be8ee921e Starship improvements after the latest gcc fixes 2020-02-12 09:48:04 +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 3decaecb52 TODO comments clean-up 2019-12-17 20:15:38 +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 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 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 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 f31b26b5e5 Design cleanup
- unknown_unit added
- examples refactored
- base_type renamed to downcast_base_type
- scaled_unit renamed to named_scaled_unit
- detail::reference_unit renamed to scaled_unit
- quantity_test cleanup
2019-12-06 12:18:39 +01:00
Mateusz Pusz c48bfe2098 quantity refactored and quantity_test enabled 2019-12-04 17:46:19 +01:00
Mateusz Pusz 3d2c613dcb quantity operators * and / constrains weaken to one magma 2019-11-16 18:29:32 +01:00
Mateusz Pusz d4976caf1d operator- constraints fixed 2019-11-16 18:28:13 +01:00
Mateusz Pusz 9c6229302d Small code cleanup 2019-11-16 18:27:31 +01:00
Mateusz Pusz 57e464cc99 quantity constraints refactored 2019-11-15 20:20:25 +01:00
Mateusz Pusz 2328a26992 Downcasting support added to quantity_cast (resolves #26) 2019-11-09 14:42:06 +00:00
Mateusz Pusz 4d1e225d9e UnitRep renamed to QuantityRep 2019-11-09 14:16:37 +00:00
Mateusz Pusz 04cbeb841e Disabled prefix/postfix increment/decrement operators (resolves #18) 2019-11-09 14:09:30 +00:00
Mateusz Pusz ad895b4651 Small refactoring of QuantityOf 2019-11-08 14:35:18 +00:00
Mateusz Pusz 9871cf0ed7 UnitRep extended 2019-11-06 21:51:40 +00:00
Mateusz Pusz e4cd4ea8c8 UnitRep concept introduced 2019-11-06 20:17:16 +00:00
Mateusz Pusz b5b2c54fe8 Basic std::fmt support added 2019-11-05 20:05:11 +00:00
Mateusz Pusz 91bcfedf1e Deduced units symbols refactoring started 2019-11-04 06:45:56 +00:00
Mateusz Pusz 7da63eedfd quantity refactoring 2019-11-02 13:58:10 +01:00
Mateusz Pusz 2bde0e62b2 Downcasting facility refactoring 2019-11-02 13:54:43 +01:00
Mateusz Pusz 53720c82b8 fmt support started 2019-10-18 23:50:43 +02:00
Mateusz Pusz b864461636 Prefixed units support redesigned 2019-10-18 15:34:46 +02:00
Mateusz Pusz 95028d10a7 gcc-10 enabled 2019-10-17 18:22:51 +02:00