Commit Graph

71 Commits

Author SHA1 Message Date
Mateusz Pusz a300614308 test: a few more quantity construction unit tests added 2026-05-21 18:45:22 +02:00
Mateusz Pusz e2e490f0cd refactor: scaling algorithm and concepts simplified 2026-04-11 19:00:33 +02:00
Mateusz Pusz d8b72fc431 refactor: scaling the value by magnitude heavily refactored 2026-03-19 00:28:15 +01:00
Mateusz Pusz cdb228d5f5 fix: cartesian_vector fixed to work properly as a representation type and enable multiply syntax 2026-03-15 07:04:02 +01:00
Mateusz Pusz 6cad11a3b9 test: remove redundant floating-point cross-unit comparison assertion
Floating-point comparisons always compile for any unit ratio; the
purpose of this block is to verify integer comparisons are SFINAE'd
out, which is already covered by no_cross_unit_int_comparison.
2026-03-08 22:19:12 +01:00
Mateusz Pusz 0eea272ece fix: overflow-safe cross-unit integer comparisons using double-width arithmetic
- Add `comparable_in_wide_type` / `CommonlyComparableQuantities` concept and
  `compare_quantities` helper in `quantity.h` that widens int reps to
  `double_width_int_for_t<Rep>` (__int128 for int64) before scaling, preventing
  silent overflow in cross-unit `operator==` / `operator<=>`
- Add `try_get_value<T>` to `unit_magnitude` returning `std::optional<T>`
  (nullopt on overflow) and refactor `get_value<T>` unsigned path to delegate
  to it; extract logic into free `try_accumulate_element<T,M>` helper taking M
  as NTTP so GCC 12 treats it as a constant expression
- Wire `scaling_overflows_non_zero_values` in `value_cast.h` through
  `try_get_value` so extreme ratios (e.g. km³ vs pm³) no longer abort at
  compile time when evaluated inside `requires`
- Add positive tests (lb vs kg, km vs mi) exercising the int64→int128 widening
  path in `yard_pound_test.cpp`
- Add negative tests using `no_cross_unit_int_comparison` template wrapper
  (necessary for soft SFINAE failure on GCC) for cubic(km)/cubic(pm),
  Zm/am (linear, factor=10^39>2^127) and cubic(mi)/cubic(pm)
2026-03-08 20:15:35 +01:00
Mateusz Pusz 6f3ef66d4b feat: comparisons against literal 0
Resolves #487
2026-02-23 11:07:22 +01:00
Mateusz Pusz 04e3d08cb9 fix: dimensionless quantitites truncation prevention fixed 2026-02-12 14:07:56 +01:00
Mateusz Pusz d194af7b97 fix: some stupid MSVC errors workarounds 2026-02-04 23:06:03 +01:00
Mateusz Pusz d74f4acc57 feat: unit_for, reference_for, and rep_for added 2026-01-28 19:28:31 +01:00
Mateusz Pusz 916a6c1a16 feat: dimensionless quantities with unit one can be created with quantity_spec::op(Val) explicit conversions 2026-01-27 20:05:58 +01:00
Mateusz Pusz 63f55959a2 feat: explicit construction from number enabled for dimensionless subkinds 2026-01-21 18:38:24 +01:00
Mateusz Pusz 9a374a5646 refactor: isq::time swapped with isq::duration 2026-01-09 09:22:37 +01:00
Mateusz Pusz 85e9a722a9 test: multiply syntax uint tests added 2026-01-07 13:29:50 +01:00
Mateusz Pusz 86e3bf5a06 fix: recursive concepts evaluation fixed
Resolves #740
2026-01-07 13:26:30 +01:00
Radnyx cc25814e82 formatting 2025-10-09 16:35:52 -07:00
Radnyx ef0e653dfe fix: seconds literal has unspecified type and depends on implementation 2025-10-09 16:35:06 -07:00
Mateusz Pusz 9c140f4b3a feat: explicit constructor now can perform an explicit quantity_spec conversion 2025-06-20 17:10:34 +02:00
Mateusz Pusz f18aa18869 refactor: compund assignment and pre-/post-increment operators are now lvalue-qualified member functions 2025-06-19 18:49:21 +02:00
Mateusz Pusz e9c5f7236e feat: ConvertibleWithNumber introduced to improve convertibility of unit one with raw numbers
Resolves #675
2025-02-11 21:28:15 +01:00
Mateusz Pusz 47a82f466c refactor: scalar and complex renamed to real_scalar and complex_scalar respectively + concepts refactoring + electromagnetism fixes 2025-02-11 17:26:19 +01:00
Mateusz Pusz 5d4e1aa740 feat: might_store_converted_common_value added to detect conversions overflowing rep
Resolves #670, resolves #671, resolves #658, resolves #303
2025-02-06 15:28:55 +01:00
Mateusz Pusz 0b14d69539 feat: quantity::one() removed
Related to #408
2025-02-05 12:08:32 +01:00
Mateusz Pusz 06cbfae3b3 feat: quantity_spec conversions improved 2024-12-28 14:02:03 +01:00
Mateusz Pusz 465f88d500 refactor: 💥 is_XXX customization points for representation types removed 2024-11-26 14:48:08 +01:00
Mateusz Pusz 9a0f7a25dd test: tests for dimensionless quantities static data members 2024-11-23 19:35:59 +01:00
Mateusz Pusz 4f8e959b5c fix(test): shadowing warnings on gcc fixed 2024-11-16 08:28:39 +01:00
Mateusz Pusz 08e94171cb test: vector quantities unit tests addded 2024-11-15 12:59:18 +01:00
Mateusz Pusz 5097096915 test: lots of tests for complex quantities 2024-11-07 18:42:20 +01:00
Mateusz Pusz da50348115 feat: 💥 RepresentationOf concept now also accepts a QuantitySpec and accepts any representation character for quantity kinds 2024-11-07 18:39:32 +01:00
Mateusz Pusz 75b50b8d2c feat: complex.h added 2024-11-07 10:58:51 +01:00
Mateusz Pusz 6896d8e086 fix: velocity is now defined in terms of displacement instead of position_vector 2024-11-06 18:46:01 +01:00
Mateusz Pusz c7303cc5fb refactor: representation concepts refactored + some quantities switched to complex 2024-11-05 19:09:16 +01:00
Mateusz Pusz f461cf479b test: test for lack of consitency between op+ and op+= for quantity_point 2024-11-04 09:41:11 +01:00
Mateusz Pusz 8ca8270d2f feat: from now on truncation is not allowed in compound assignment 2024-10-30 08:40:49 +01:00
Mateusz Pusz 18525beb31 test: small refactoring of compund assignment tests 2024-10-29 10:20:11 +01:00
Mateusz Pusz 7445585db8 fix: compound assignment operations on quantities now behave the same as on the underying representation types
Resolves #137
2024-10-29 09:18:32 +01:00
Mateusz Pusz 00847ab558 fix(tests): freestanding build fixed 2024-10-16 17:22:59 +02:00
Mateusz Pusz 21784b125e refactor: derived_quantity refactored to child_quantity 2024-10-15 21:06:52 +02:00
Mateusz Pusz 3eecdf3946 test: commutativity tests added to ISQ 2024-10-15 21:06:18 +02:00
Mateusz Pusz 569f27af8b fix: common_unit handling fixed for some corner cases 2024-10-05 17:52:52 +02:00
Mateusz Pusz 7ce8d695b1 test: std::complex-based quantities tests added 2024-09-17 12:48:13 -06:00
Mateusz Pusz 0670fbdd9f feat: value_cast<Representation, Unit>() complementary conversion function added 2024-09-13 21:38:59 +02:00
Mateusz Pusz 3d39472f46 test: unit tests for creating a quantity from a volatile variable 2024-09-06 18:07:33 +02:00
Mateusz Pusz 1570bda905 fix: quantity scaling between different prefixes improved
Resolves #608
2024-09-06 12:28:11 +02:00
Mateusz Pusz 2e840cfdb4 refactor: Repetitive inline constexpr removed as no longer needed
Not needed anymore as stated in cplusplus/draft#4601
2024-09-05 08:43:36 +02:00
Chip Hogg 3a6fac9858 Move tests to runtime 2024-07-24 20:04:15 -04:00
Chip Hogg f6696e8f68 Fix formatting 2024-07-24 19:48:05 -04:00
Chip Hogg 7e894788d7 Compute values for rational magnitude powers
Since this will only ever be done at compile time (as guaranteed by
using `consteval`), we can afford to prioritize precision over speed.
To compute an Nth root, we simply do a binary search over representable
floating point numbers, looking for the number whose Nth power most
closely matches the original number.

Fixes #494.  We have included a test case reproducing the original
problem exactly.  All tests use "within 4 ULPs" as the criterion, which
is (I believe) equivalent to the googletest `EXPECT_DOUBLE_EQ`
criterion.
2024-07-24 10:31:44 -04:00
Mateusz Pusz b870b85c25 feat: import std; support added
Resolves #595
2024-07-16 17:36:00 +02:00