├── docs ├── contents.rst ├── reference │ ├── Rec20_units.xlsx │ ├── containers.txt │ ├── currencydata.txt │ ├── rec20_Rev7e_2010.pdf │ ├── rec20_Rev7e_2010.xls │ ├── 2004-09-10_UOMCodes.pdf │ ├── rec21rev1_ecetrd195e.pdf │ ├── ANSI_ASC_X12_code_sequence.xlsx │ ├── ANSI_UNITS_OF_MEASURE_20120209.pdf │ └── generate_currency_codes.py ├── introduction │ ├── sources.rst │ ├── how.rst │ └── converter.rst ├── requirements.txt ├── details │ ├── index.rst │ └── string_parsing_squared.rst ├── application_notes │ └── index.rst ├── _static │ ├── css │ │ └── custom.css │ └── convert.html ├── Makefile ├── user-guide │ ├── index.rst │ ├── special_units.rst │ ├── measurements.rst │ ├── python.rst │ ├── fixed_measurements.rst │ └── math_operations.rst ├── make.bat ├── web │ └── index.rst └── index.rst ├── config ├── spelling_ignorelines.txt ├── spelling_whitelist.txt ├── cppcheck_suppressions.txt ├── unitsConfig.cmake.in └── .markdownlintrc ├── test ├── files │ ├── Physics_constants.txt │ ├── fuzz_issues │ │ ├── crash12 │ │ ├── crash9 │ │ ├── meas_fail1 │ │ ├── meas_fail24 │ │ ├── meas_fail28 │ │ ├── meas_fail3 │ │ ├── meas_fail32 │ │ ├── meas_fail4 │ │ ├── meas_fail5 │ │ ├── rtrip_fail4 │ │ ├── rtrip_fail9 │ │ ├── meas64_fail1 │ │ ├── meas64_fail4 │ │ ├── meas_fail15 │ │ ├── meas_fail29 │ │ ├── meas_fail30 │ │ ├── rtrip_fail33 │ │ ├── rtrip_fail34 │ │ ├── rtrip_fail35 │ │ ├── rtrip_fail7 │ │ ├── crash18 │ │ ├── crash25 │ │ ├── crash6 │ │ ├── meas64_fail5 │ │ ├── meas_fail20 │ │ ├── rtrip_fail12 │ │ ├── rtrip_fail2 │ │ ├── rtrip_fail28 │ │ ├── rtrip_fail32 │ │ ├── rtrip_flag1 │ │ ├── meas64_fail3 │ │ ├── rtrip_fail18 │ │ ├── crash13 │ │ ├── meas_fail16 │ │ ├── rtrip_fail10 │ │ ├── rtrip_fail25 │ │ ├── meas_fail14 │ │ ├── meas_fail17 │ │ ├── meas_fail18 │ │ ├── slow1 │ │ ├── slow12 │ │ ├── slow2 │ │ ├── slow9 │ │ ├── timeout7 │ │ ├── meas_fail23 │ │ ├── slow16 │ │ ├── timeout5 │ │ ├── slow13 │ │ ├── meas_fail9 │ │ ├── oom1 │ │ ├── rtrip_fail31 │ │ ├── slow15 │ │ ├── slow6 │ │ ├── meas_fail22 │ │ ├── rtrip_fail1 │ │ ├── slow18 │ │ ├── meas_fail11 │ │ ├── oom10 │ │ ├── oom11 │ │ ├── oom12 │ │ ├── oom13 │ │ ├── oom14 │ │ ├── oom15 │ │ ├── oom16 │ │ ├── oom17 │ │ ├── oom18 │ │ ├── oom19 │ │ ├── oom2 │ │ ├── oom20 │ │ ├── oom21 │ │ ├── oom22 │ │ ├── oom23 │ │ ├── oom24 │ │ ├── oom25 │ │ ├── oom26 │ │ ├── oom27 │ │ ├── oom28 │ │ ├── oom29 │ │ ├── oom3 │ │ ├── oom30 │ │ ├── oom31 │ │ ├── oom32 │ │ ├── oom33 │ │ ├── oom34 │ │ ├── oom35 │ │ ├── oom36 │ │ ├── oom37 │ │ ├── oom38 │ │ ├── oom39 │ │ ├── oom4 │ │ ├── oom40 │ │ ├── oom41 │ │ ├── oom42 │ │ ├── oom43 │ │ ├── oom44 │ │ ├── oom45 │ │ ├── oom46 │ │ ├── oom47 │ │ ├── oom48 │ │ ├── oom49 │ │ ├── oom5 │ │ ├── oom50 │ │ ├── oom51 │ │ ├── oom52 │ │ ├── oom53 │ │ ├── oom54 │ │ ├── oom55 │ │ ├── oom56 │ │ ├── oom57 │ │ ├── oom58 │ │ ├── oom59 │ │ ├── oom6 │ │ ├── oom60 │ │ ├── oom61 │ │ ├── oom62 │ │ ├── oom63 │ │ ├── oom64 │ │ ├── oom65 │ │ ├── oom7 │ │ ├── oom8 │ │ ├── oom9 │ │ ├── slow3 │ │ ├── slow4 │ │ ├── slow5 │ │ ├── slow7 │ │ ├── slow8 │ │ ├── crash1 │ │ ├── crash10 │ │ ├── crash11 │ │ ├── crash14 │ │ ├── crash15 │ │ ├── crash16 │ │ ├── crash17 │ │ ├── crash19 │ │ ├── crash2 │ │ ├── crash20 │ │ ├── crash21 │ │ ├── crash22 │ │ ├── crash23 │ │ ├── crash24 │ │ ├── crash26 │ │ ├── crash27 │ │ ├── crash28 │ │ ├── crash3 │ │ ├── crash4 │ │ ├── crash5 │ │ ├── crash7 │ │ ├── crash8 │ │ ├── meas_fail10 │ │ ├── slow10 │ │ ├── slow11 │ │ ├── slow14 │ │ ├── slow17 │ │ ├── slow19 │ │ ├── slow20 │ │ ├── slow21 │ │ ├── slow22 │ │ ├── slow23 │ │ ├── slow24 │ │ ├── slow25 │ │ ├── slow26 │ │ ├── slow27 │ │ ├── slow28 │ │ ├── slow29 │ │ ├── slow30 │ │ ├── slow31 │ │ ├── slow32 │ │ ├── slow33 │ │ ├── slow34 │ │ ├── slow35 │ │ ├── slow36 │ │ ├── slow37 │ │ ├── slow38 │ │ ├── slow39 │ │ ├── slow40 │ │ ├── timeout1 │ │ ├── timeout2 │ │ ├── timeout3 │ │ ├── timeout4 │ │ ├── timeout6 │ │ ├── timeout8 │ │ ├── timeout9 │ │ ├── meas_fail2 │ │ ├── meas_fail6 │ │ ├── meas_fail7 │ │ ├── meas_fail8 │ │ ├── timeout10 │ │ ├── timeout11 │ │ ├── timeout12 │ │ ├── timeout13 │ │ ├── timeout14 │ │ ├── timeout15 │ │ ├── timeout16 │ │ ├── timeout17 │ │ ├── timeout18 │ │ ├── timeout19 │ │ ├── timeout20 │ │ ├── timeout21 │ │ ├── timeout22 │ │ ├── timeout23 │ │ ├── timeout24 │ │ ├── timeout25 │ │ ├── timeout26 │ │ ├── timeout27 │ │ ├── timeout28 │ │ ├── meas64_fail2 │ │ ├── meas_fail12 │ │ ├── meas_fail13 │ │ ├── meas_fail19 │ │ ├── meas_fail21 │ │ ├── meas_fail25 │ │ ├── meas_fail26 │ │ ├── meas_fail27 │ │ ├── meas_fail31 │ │ ├── rtrip_fail11 │ │ ├── rtrip_fail13 │ │ ├── rtrip_fail14 │ │ ├── rtrip_fail15 │ │ ├── rtrip_fail16 │ │ ├── rtrip_fail17 │ │ ├── rtrip_fail19 │ │ ├── rtrip_fail20 │ │ ├── rtrip_fail21 │ │ ├── rtrip_fail22 │ │ ├── rtrip_fail23 │ │ ├── rtrip_fail24 │ │ ├── rtrip_fail26 │ │ ├── rtrip_fail27 │ │ ├── rtrip_fail29 │ │ ├── rtrip_fail3 │ │ ├── rtrip_fail30 │ │ ├── rtrip_fail36 │ │ ├── rtrip_fail37 │ │ ├── rtrip_fail5 │ │ ├── rtrip_fail6 │ │ ├── rtrip_fail8 │ │ ├── rtrip_flag2 │ │ ├── rtrip_flag3 │ │ ├── rtrip_flag4 │ │ ├── rtrip_flag5 │ │ ├── rtrip_flag6 │ │ └── rtrip_flag7 │ ├── test_units_unicode.txt │ ├── google_defined_units.txt │ ├── test_conversions │ │ ├── sound_conversions.txt │ │ ├── luminosity_conversions.txt │ │ ├── temperature_conversions.txt │ │ ├── computer_speed_conversions.txt │ │ ├── mmf_conversions.txt │ │ ├── mol_conversions.txt │ │ ├── absorbed_dose_conversions.txt │ │ ├── potential_conversions.txt │ │ ├── resistance_conversions.txt │ │ ├── thermal_resistance_conversions.txt │ │ ├── angle_conversions.txt │ │ ├── exposure_conversions.txt │ │ ├── number_conversions.txt │ │ ├── mass_flux_conversions.txt │ │ ├── conductance_conversions.txt │ │ ├── typography_conversions.txt │ │ ├── illumination_conversions.txt │ │ ├── fraction_conversions.txt │ │ ├── mag_field_conversions.txt │ │ ├── linear_mass_conversions.txt │ │ ├── charge_conversions.txt │ │ ├── activity_conversions.txt │ │ ├── heat_transfer_conversions.txt │ │ ├── current_conversions.txt │ │ ├── inductance_conversions.txt │ │ ├── capacitance_conversions.txt │ │ ├── luminance_conversions.txt │ │ ├── thermal_conductivity_conversions.txt │ │ ├── fuel_consumption_conversions.txt │ │ ├── mag_flux_conversions.txt │ │ ├── dose_conversions.txt │ │ ├── concentration_ratio_conversions.txt │ │ ├── enzyme_activity_conversions.txt │ │ ├── time_conversions.txt │ │ ├── kinematic_viscosity_conversions.txt │ │ ├── viscosity_conversions.txt │ │ ├── molar_flow_conversions.txt │ │ ├── surface_current_conversions.txt │ │ ├── concentration_conversions.txt │ │ ├── molar_concentration_conversions.txt │ │ ├── area_conversions.txt │ │ ├── force_conversions.txt │ │ ├── force_moment_conversions.txt │ │ ├── heat_flux_conversions.txt │ │ ├── data_transfer_conversions.txt │ │ ├── mass_flow_conversions.txt │ │ ├── velocity_conversions.txt │ │ ├── volume_concentration_conversions.txt │ │ ├── mass_conversions.txt │ │ ├── surface_tension_conversions.txt │ │ ├── radiation_conversions.txt │ │ ├── conductivity_conversions.txt │ │ ├── angular_velocity_conversions.txt │ │ ├── angular_accel_conversions.txt │ │ ├── pressure_conversions.txt │ │ ├── surface_charge_conversions.txt │ │ ├── energy_conversions.txt │ │ ├── distance_conversions.txt │ │ └── resistivity_conversions.txt │ ├── test_units_unicode_u8.txt │ ├── test_unit_files │ │ ├── other_units2.txt │ │ ├── other_units.txt │ │ ├── other_units4.txt │ │ ├── bad_unit_definitions.txt │ │ └── other_units3.txt │ ├── SI_Units.csv │ ├── si_examples.csv │ └── UDUNITS2 │ │ └── UDUNITS2_COPYRIGHT.txt ├── test.hpp ├── pkg_test_code │ ├── main.cpp │ └── header_only.cpp ├── CPPLINT.cfg ├── test_all_unit_base.cpp ├── python │ ├── test_conversion.py │ └── test_user_defined.py ├── examples_test.cpp ├── examples_test_windows.cpp ├── find_package_tests │ └── CMakeLists.txt └── test_random_round_trip.cpp ├── .circleci ├── asan_blacklist.txt └── leak_suppression.txt ├── webserver ├── web_script.sh ├── hooks │ └── build ├── CPPLINT.cfg ├── Dockerfile ├── index.html ├── convert.html └── CMakeLists.txt ├── .gitmodules ├── FuzzTargets ├── hooks │ └── build ├── fuzz_script.sh ├── Dockerfile ├── CMakeLists.txt ├── fuzz_target_from_string.cpp └── fuzz_target_measurement_from_string.cpp ├── .gitignore ├── .readthedocs.yml ├── .ci ├── azure-test.yml ├── azure-build.yml ├── azure-steps.yml ├── build_lcov.sh ├── make_and_test.sh ├── quick_fuzz.sh ├── build_doxygen.sh ├── check_tidy.sh └── azure-cmake.yml ├── .codacy.yml ├── .cmake-format.json ├── .prettierrc ├── .github ├── dependabot.yml ├── workflows │ ├── arm_mac_gcc.yml │ ├── freebsd.yml │ ├── static-analyzers.yml │ └── coverage.yml └── actions │ └── quick_cmake │ └── action.yml ├── python └── units_llnl │ └── __init__.py ├── .codecov.yml ├── CPPLINT.cfg ├── ThirdParty └── cmake │ ├── Utils.cmake │ └── extraMacros.cmake ├── NOTICE ├── LICENSE ├── converter └── CMakeLists.txt ├── .pre-commit-config.yaml └── pyproject.toml /docs/contents.rst: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /config/spelling_ignorelines.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/files/Physics_constants.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash12: -------------------------------------------------------------------------------- 1 | per1 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash9: -------------------------------------------------------------------------------- 1 | Nper(1 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail1: -------------------------------------------------------------------------------- 1 | *r' -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail24: -------------------------------------------------------------------------------- 1 | MMNp -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail28: -------------------------------------------------------------------------------- 1 | AA-S -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail3: -------------------------------------------------------------------------------- 1 | Zl -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail32: -------------------------------------------------------------------------------- 1 | pdu -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail4: -------------------------------------------------------------------------------- 1 | pe7 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail5: -------------------------------------------------------------------------------- 1 | -2)0 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail4: -------------------------------------------------------------------------------- 1 | cgcu -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail9: -------------------------------------------------------------------------------- 1 | CGA -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas64_fail1: -------------------------------------------------------------------------------- 1 | -st3 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas64_fail4: -------------------------------------------------------------------------------- 1 | /ar9 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail15: -------------------------------------------------------------------------------- 1 | A1Z0-1+ -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail29: -------------------------------------------------------------------------------- 1 | T-TT- -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail30: -------------------------------------------------------------------------------- 1 | /<>y-³' -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail33: -------------------------------------------------------------------------------- 1 | 36Nm -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail34: -------------------------------------------------------------------------------- 1 | AtMcu. -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail35: -------------------------------------------------------------------------------- 1 | ^1G/AX^ -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail7: -------------------------------------------------------------------------------- 1 | --0-5 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash18: -------------------------------------------------------------------------------- 1 | tmP-0({-f})2 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash25: -------------------------------------------------------------------------------- 1 | ++++6+++++++++++ -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash6: -------------------------------------------------------------------------------- 1 | 10 0101011010011 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas64_fail5: -------------------------------------------------------------------------------- 1 | meter^33b -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail20: -------------------------------------------------------------------------------- 1 | squacenti6- -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail12: -------------------------------------------------------------------------------- 1 | {U,}UU{\}U}D -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail2: -------------------------------------------------------------------------------- 1 | m6^11^11^1^2 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail28: -------------------------------------------------------------------------------- 1 | -st√Hz..1 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail32: -------------------------------------------------------------------------------- 1 | G/AN -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_flag1: -------------------------------------------------------------------------------- 1 | Ch5TT.F.A -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas64_fail3: -------------------------------------------------------------------------------- 1 | N- 5555504104kg^8 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail18: -------------------------------------------------------------------------------- 1 | 16/giAb/giAb -------------------------------------------------------------------------------- /config/spelling_whitelist.txt: -------------------------------------------------------------------------------- 1 | smoot 2 | ThirdParty 3 | -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash13: -------------------------------------------------------------------------------- 1 | -2 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail16: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail10: -------------------------------------------------------------------------------- 1 | cccd -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail25: -------------------------------------------------------------------------------- 1 | 0perunit/eflag4|F(.)^26 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail14: -------------------------------------------------------------------------------- 1 | $2^{3/0A/ ^35)^3/0A0 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail17: -------------------------------------------------------------------------------- 1 | pupt.pupt.EQXUN[86]999999 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail18: -------------------------------------------------------------------------------- 1 | pupt.pupt.EQXUN[41]999999 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow1: -------------------------------------------------------------------------------- 1 | MOUUKKUMUKMOUUKKUMUKiLofLiLofLo -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow12: -------------------------------------------------------------------------------- 1 | MOUKUMUKMUKLLUKMUUKMUKKMUUKMUKMUK -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow2: -------------------------------------------------------------------------------- 1 | mmmmT()()()RZ()()()()ofofB()ofofB? -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow9: -------------------------------------------------------------------------------- 1 | PuPuPu(())BuPuPu(())(())B()BB.0() -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout7: -------------------------------------------------------------------------------- 1 | G%G%G%G%G%G%G%YUSSUSUSVUUSSV`USUU -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail23: -------------------------------------------------------------------------------- 1 | us.s.EQXUN[8]999999 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow16: -------------------------------------------------------------------------------- 1 | rperperM}A}A}UKA0}}M|}}A}}}Xi1}}UK}}}U]A}}u -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout5: -------------------------------------------------------------------------------- 1 | MOUKUMUKUMUKMUKLUKMUKMUKUKMUKLUKMUKMUK -------------------------------------------------------------------------------- /.circleci/asan_blacklist.txt: -------------------------------------------------------------------------------- 1 | src:*/libzmq/* 2 | src:*/badInputTests.cpp 3 | -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow13: -------------------------------------------------------------------------------- 1 | AAperperUS}}}+perpeper,per}+perperUS}}per,per}+ -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail9: -------------------------------------------------------------------------------- 1 | 4444444444444044244444square444444444444444Gys-4 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom1: -------------------------------------------------------------------------------- 1 | }}UK}D}}}}UK}D}}UK}DB}UK}DB}UB}UKUK}DB}UK}DB}UB}UK}DB}U -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail31: -------------------------------------------------------------------------------- 1 | ST-9999999998999999999999999999999999999$999999 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow15: -------------------------------------------------------------------------------- 1 | AperUS}pe}AperUS}pe}per},}r},}per},}US}pe}per},r},}+ -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow6: -------------------------------------------------------------------------------- 1 | MmMmQ0((()(()%3:)1of2)1of1oQ0((()(()%3:)1of2)1of1of -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail22: -------------------------------------------------------------------------------- 1 | us.s.EQXUN[8]999999 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail1: -------------------------------------------------------------------------------- 1 | 10*610*610*210*110*610*610*21*610*0*2**1 *6111*12*1*1 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow18: -------------------------------------------------------------------------------- 1 | peperper[]perze+perper[]perze+eper[]pu]perper[]perzetper] -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail11: -------------------------------------------------------------------------------- 1 | /6/6/6^)^6/6/6/6^)^6/6/(1)^/6/6(1)^/6/6/ -------------------------------------------------------------------------------- /.circleci/leak_suppression.txt: -------------------------------------------------------------------------------- 1 | # This is a known purposeful leak 2 | leak:ZmqContextManager 3 | -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom10: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom10 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom11 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom12 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom13: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom13 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom14: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom14 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom15: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom15 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom16 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom17: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom17 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom18: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom18 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom19: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom19 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom2 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom20: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom20 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom21: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom21 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom22: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom22 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom23: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom23 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom24: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom24 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom25: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom25 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom26: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom26 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom27: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom27 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom28: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom28 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom29: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom29 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom3 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom30: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom30 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom31: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom31 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom32 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom33: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom33 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom34: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom34 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom35: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom35 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom36: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom36 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom37: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom37 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom38: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom38 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom39: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom39 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom4 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom40: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom40 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom41: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom41 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom42: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom42 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom43: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom43 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom44: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom44 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom45: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom45 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom46: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom46 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom47: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom47 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom48: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom48 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom49: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom49 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom5 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom50: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom50 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom51: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom51 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom52: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom52 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom53: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom53 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom54: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom54 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom55: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom55 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom56: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom56 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom57: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom57 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom58: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom58 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom59: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom59 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom6 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom60: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom60 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom61: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom61 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom62: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom62 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom63: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom63 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom64: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom64 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom65: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom65 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom7 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom8 -------------------------------------------------------------------------------- /test/files/fuzz_issues/oom9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/oom9 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow3 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow4 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow5 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow7 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow8 -------------------------------------------------------------------------------- /webserver/web_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # run the webserver 4 | ./units_webserver 0.0.0.0 80 5 | -------------------------------------------------------------------------------- /docs/reference/Rec20_units.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/docs/reference/Rec20_units.xlsx -------------------------------------------------------------------------------- /docs/reference/containers.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/docs/reference/containers.txt -------------------------------------------------------------------------------- /docs/reference/currencydata.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/docs/reference/currencydata.txt -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash1 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash10: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash10 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash11 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash14: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash14 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash15: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash15 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash16 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash17: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash17 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash19: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash19 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash2 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash20: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash20 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash21: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash21 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash22: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash22 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash23: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash23 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash24: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash24 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash26: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash26 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash27: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash27 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash28: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash28 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash3 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash4 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash5 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash7 -------------------------------------------------------------------------------- /test/files/fuzz_issues/crash8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/crash8 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail10: -------------------------------------------------------------------------------- 1 | 4444444444444444444per4444444444444444444444444444444444444444444444244 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow10: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow10 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow11 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow14: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow14 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow17: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow17 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow19: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow19 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow20: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow20 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow21: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow21 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow22: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow22 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow23: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow23 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow24: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow24 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow25: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow25 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow26: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow26 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow27: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow27 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow28: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow28 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow29: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow29 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow30: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow30 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow31: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow31 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow32: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow32 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow33: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow33 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow34: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow34 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow35: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow35 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow36: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow36 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow37: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow37 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow38: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow38 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow39: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow39 -------------------------------------------------------------------------------- /test/files/fuzz_issues/slow40: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/slow40 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout1: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout1 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout2 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout3 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout4 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout6 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout8 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout9: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout9 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail2 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail6 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail7 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail8 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout10: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout10 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout11 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout12 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout13: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout13 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout14: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout14 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout15: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout15 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout16 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout17: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout17 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout18: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout18 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout19: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout19 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout20: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout20 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout21: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout21 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout22: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout22 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout23: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout23 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout24: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout24 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout25: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout25 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout26: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout26 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout27: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout27 -------------------------------------------------------------------------------- /test/files/fuzz_issues/timeout28: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/timeout28 -------------------------------------------------------------------------------- /test/files/test_units_unicode.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/test_units_unicode.txt -------------------------------------------------------------------------------- /docs/reference/rec20_Rev7e_2010.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/docs/reference/rec20_Rev7e_2010.pdf -------------------------------------------------------------------------------- /docs/reference/rec20_Rev7e_2010.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/docs/reference/rec20_Rev7e_2010.xls -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas64_fail2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas64_fail2 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail12: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail12 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail13: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail13 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail19: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail19 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail21: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail21 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail25: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail25 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail26: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail26 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail27: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail27 -------------------------------------------------------------------------------- /test/files/fuzz_issues/meas_fail31: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/meas_fail31 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail11: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail11 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail13: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail13 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail14: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail14 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail15: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail15 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail16: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail16 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail17: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail17 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail19: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail19 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail20: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail20 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail21: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail21 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail22: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail22 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail23: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail23 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail24: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail24 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail26: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail26 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail27: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail27 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail29: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail29 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail3 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail30: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail30 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail36: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail36 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail37: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail37 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail5 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail6 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_fail8: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_fail8 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_flag2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_flag2 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_flag3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_flag3 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_flag4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_flag4 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_flag5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_flag5 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_flag6: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_flag6 -------------------------------------------------------------------------------- /test/files/fuzz_issues/rtrip_flag7: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/fuzz_issues/rtrip_flag7 -------------------------------------------------------------------------------- /test/files/google_defined_units.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/test/files/google_defined_units.txt -------------------------------------------------------------------------------- /docs/reference/2004-09-10_UOMCodes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/docs/reference/2004-09-10_UOMCodes.pdf -------------------------------------------------------------------------------- /test/files/test_conversions/sound_conversions.txt: -------------------------------------------------------------------------------- 1 | bel [B]: 2 | 34.5 3 | decibel [dB]: 4 | 345 5 | neper [Np]: 6 | 39.719088 -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "googletest"] 2 | path = ThirdParty/googletest 3 | url = https://github.com/google/googletest.git 4 | -------------------------------------------------------------------------------- /docs/reference/rec21rev1_ecetrd195e.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/docs/reference/rec21rev1_ecetrd195e.pdf -------------------------------------------------------------------------------- /webserver/hooks/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | docker build --build-arg GIT_COMMIT=$SOURCE_COMMIT -f $DOCKERFILE_PATH -t $IMAGE_NAME . 3 | -------------------------------------------------------------------------------- /FuzzTargets/hooks/build: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | docker build --build-arg GIT_COMMIT=$SOURCE_COMMIT -f $DOCKERFILE_PATH -t $IMAGE_NAME . 3 | -------------------------------------------------------------------------------- /test/files/test_units_unicode_u8.txt: -------------------------------------------------------------------------------- 1 | m/s² 2 | kg×m/s³ 3 | N·m·s 4 | °C 5 | °F 6 | ° 7 | mi ÷ hr 8 | µm 9 | µN 10 | µkg 11 | -------------------------------------------------------------------------------- /docs/reference/ANSI_ASC_X12_code_sequence.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/docs/reference/ANSI_ASC_X12_code_sequence.xlsx -------------------------------------------------------------------------------- /docs/reference/ANSI_UNITS_OF_MEASURE_20120209.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/LLNL/units/HEAD/docs/reference/ANSI_UNITS_OF_MEASURE_20120209.pdf -------------------------------------------------------------------------------- /test/files/test_conversions/luminosity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. candle [CP]: 2 | 1.019 3 | 10. lumen/steradian [lm/sr]: 4 | 1 5 | 11. candela: 6 | 1 7 | 8 | -------------------------------------------------------------------------------- /test/files/test_unit_files/other_units2.txt: -------------------------------------------------------------------------------- 1 | # comment 2 | yodles=73 counts 3 | 4 | # comment 5 | yeedles, 19 yodles 6 | 7 | "yimdles"; "twelve yeedles" -------------------------------------------------------------------------------- /test/files/test_unit_files/other_units.txt: -------------------------------------------------------------------------------- 1 | # comment 2 | meeter == meter 3 | meh == meeter per hour 4 | # => indicates input only unit 5 | mehmeh => meh/s -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build*/ 2 | ~$*.xlsx 3 | nanobind_test.egg-info 4 | _skbuild 5 | /dist 6 | __pycache__ 7 | build 8 | *.pyd 9 | *.egg-info 10 | .vscode 11 | .vs 12 | */*/_version.py 13 | -------------------------------------------------------------------------------- /test/files/test_conversions/temperature_conversions.txt: -------------------------------------------------------------------------------- 1 | degree Celsius [oC]: 2 | 54 3 | degree Fahrenheit [oF]: 4 | 129.2 5 | kelvin [K]: 6 | 327.15 7 | degree Rankine [degR]: 8 | 588.87 9 | degree Reaumur [degRe]: 10 | 43.2 -------------------------------------------------------------------------------- /test/files/test_unit_files/other_units4.txt: -------------------------------------------------------------------------------- 1 | # test the quotes for inclusion 2 | agV=12.2 V 3 | 4 | "auV"==14.2 V 5 | 6 | #input only unit 7 | HgV=>17.7V 8 | 9 | # output only unit 10 | FeV<=17.7V 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /docs/introduction/sources.rst: -------------------------------------------------------------------------------- 1 | ===================================== 2 | Sources of Unit String Definitions 3 | ===================================== 4 | 5 | The string processing tests and strings supported came from a number of different sources. 6 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx==7.2.6 2 | sphinx_rtd_theme==2.0.0 3 | myst-parser==2.0.0 4 | ipython==8.22.2 5 | ipykernel==6.29.3 6 | nbsphinx==0.9.3 7 | breathe==4.35.0 8 | sphinx-markdown-tables==0.0.17 9 | sphinxcontrib-svg2pdfconverter==1.2.2 10 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | 3 | formats: all 4 | 5 | build: 6 | os: ubuntu-22.04 7 | tools: 8 | python: '3.10' 9 | 10 | sphinx: 11 | configuration: docs/conf.py 12 | 13 | python: 14 | install: 15 | - requirements: docs/requirements.txt 16 | -------------------------------------------------------------------------------- /test/files/test_conversions/computer_speed_conversions.txt: -------------------------------------------------------------------------------- 1 | floating point operations per second [flops]: 2 | 1e+9 3 | kiloflops: 4 | 1000000 5 | megaflops: 6 | 1000 7 | gigaflops: 8 | 1 9 | teraflops: 10 | 0.001 11 | petaflops: 12 | 0.000001 13 | exaflops: 14 | 1e-9 -------------------------------------------------------------------------------- /test/files/test_conversions/mmf_conversions.txt: -------------------------------------------------------------------------------- 1 | ampere turn [At]: 2 | 1 3 | kiloampere turn: 4 | 0.001 5 | megaampere turn: 6 | 0.000001 7 | milliampere turn: 8 | 1000 9 | microampere turn: 10 | 1000000 11 | gilbert [Gb]: 12 | 1.256637 13 | milligilbert [mGi]: 14 | 1256.637062 -------------------------------------------------------------------------------- /docs/details/index.rst: -------------------------------------------------------------------------------- 1 | =============================================== 2 | The Low Level Details of the Units library 3 | =============================================== 4 | 5 | .. toctree:: 6 | :maxdepth: 1 7 | 8 | unit_base 9 | commodities 10 | string_parsing_squared 11 | -------------------------------------------------------------------------------- /docs/application_notes/index.rst: -------------------------------------------------------------------------------- 1 | ======================== 2 | Application Notes 3 | ======================== 4 | 5 | This folder is a collection of some example code snippets and discussions applied to various situations 6 | 7 | 8 | .. toctree:: 9 | :maxdepth: 1 10 | 11 | strain 12 | -------------------------------------------------------------------------------- /test/files/test_conversions/mol_conversions.txt: -------------------------------------------------------------------------------- 1 | moles [mol]: 2 | 1 3 | millimole [mmol]: 4 | 1000 5 | micromole [umol]: 6 | 1000000 7 | nanomole [nmol]: 8 | 1e+9 9 | picomole [pmol]: 10 | 1e+12 11 | femtomole [fmol]: 12 | 1e+15 13 | kilomole [kmol]: 14 | 0.001 15 | atoms [atoms]: 16 | 6.02e+23 -------------------------------------------------------------------------------- /.ci/azure-test.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - script: ctest --output-on-failure -C $(units.build_type) -T test 3 | displayName: "Test" 4 | workingDirectory: build 5 | 6 | - task: PublishTestResults@2 7 | inputs: 8 | testResultsFormat: "cTest" 9 | testResultsFiles: "**/Test.xml" 10 | -------------------------------------------------------------------------------- /test/files/test_conversions/absorbed_dose_conversions.txt: -------------------------------------------------------------------------------- 1 | 11. sievert [Sv]: 2 | 36.161487 3 | 12. millisievert [mSv]: 4 | 36161.48708 5 | 13. microsievert [uSv]: 6 | 36161487.08 7 | 14. rem [rem]: 8 | 3616.148708 9 | 15. millirem [mrem]: 10 | 3616148.708 11 | 16. microrem [urem]: 12 | 3.616149e+9 -------------------------------------------------------------------------------- /test/files/test_unit_files/bad_unit_definitions.txt: -------------------------------------------------------------------------------- 1 | # does not have a separator 2 | yodles 73 counts 3 | 4 | # no definition 5 | yeedles= 6 | 7 | # empty name 8 | ""=5.6meters 9 | 10 | # empty definition 11 | "gluggers"="" 12 | 13 | # invalid definition unit 14 | eetls == ham sandwich -------------------------------------------------------------------------------- /test/files/test_conversions/potential_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. volt [V]: 2 | 1 3 | 2. watt/ampere [W/A]: 4 | 1 5 | 3. kilovolt [kV]: 6 | 0.001 7 | 4. megavolt [MV]: 8 | 0.000001 9 | 5. millivolt [mV]: 10 | 1000 11 | 6. microvolt [uV]: 12 | 1000000 13 | 7. abvolt [abV]: 14 | 100000000 15 | 9. statvolt [stV]: 16 | 0.00333564 17 | -------------------------------------------------------------------------------- /test/files/test_unit_files/other_units3.txt: -------------------------------------------------------------------------------- 1 | # test the quotes for inclusion 2 | "bl==p"=18.7 cups 3 | 4 | # test single quotes for inclusion 5 | 'y,,p',9 tons 6 | 7 | #ignore just one quote 8 | 'np==14 kg 9 | 10 | #escaped quotes 11 | "j\"\""= 13.5 W 12 | 13 | #escaped quotes 14 | 'q""'= 15.5 W 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /docs/_static/css/custom.css: -------------------------------------------------------------------------------- 1 | .wy-side-nav-search { 2 | display: block; 3 | width: 300px; 4 | padding: 0.809em; 5 | margin-bottom: 0.809em; 6 | z-index: 200; 7 | background-color: #fcfcfc; 8 | text-align: center; 9 | padding: 0.809em; 10 | display: block; 11 | color: #fcfcfc; 12 | margin-bottom: 0.809em; 13 | } 14 | -------------------------------------------------------------------------------- /.codacy.yml: -------------------------------------------------------------------------------- 1 | --- 2 | engines: 3 | rubocop: 4 | enabled: true 5 | duplication: 6 | enabled: true 7 | metrics: 8 | enabled: true 9 | coverage: 10 | enabled: false 11 | languages: 12 | 13 | exclude_paths: 14 | - 'ThirdParty/**/*' 15 | - 'ThirdParty/*' 16 | - 'scripts/**/*' 17 | - 'scripts/*' 18 | - '**.md' 19 | -------------------------------------------------------------------------------- /test/files/test_conversions/resistance_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. ohm [ohm]: 2 | 10 3 | 2. megaohm [Mohm]: 4 | 0.00001 5 | 3. microohm [uohm]: 6 | 10000000 7 | 4. milliohm [mohm]: 8 | 10000 9 | 5. kiloohm [kohm]: 10 | 0.01 11 | 6. volt/ampere [V/A]: 12 | 10 13 | 7. reciprocal siemens [1/S]: 14 | 10 15 | 8. abohm: 16 | 1e+10 17 | 10. statohm: 18 | 1.11e-11 -------------------------------------------------------------------------------- /test/files/test_conversions/thermal_resistance_conversions.txt: -------------------------------------------------------------------------------- 1 | kelvin/watt [K/W]: 2 | 1 3 | degreeCelsius/watt [degC/W]: 4 | 1 5 | Fahrenheit/watt [degF/W]: 6 | 1.8 7 | Fahrenheit hour/Btu (IT): 8 | 0.527528 9 | Fahrenheit hour/Btu (th): 10 | 0.527175 11 | Fahrenheit second/Btu (IT): 12 | 1899.100535 13 | Fahrenheit second/Btu (th): 14 | 1897.830476 -------------------------------------------------------------------------------- /test/files/test_conversions/angle_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. degree: 2 | 1 3 | 2. radian [rad]: 4 | 0.01745329 5 | 3. grad: 6 | 1.111111 7 | 4. gon: 8 | 1.111111 9 | 5. arcminute: 10 | 60 11 | 6. arcsecond: 12 | 3600 13 | 8. mil(angle): 14 | 17.777778 15 | 9. revolution [r]: 16 | 0.0027777778 17 | 10. circle: 18 | 0.0027777778 19 | 12. quadrant: 20 | 0.01111111 21 | -------------------------------------------------------------------------------- /test/files/test_conversions/exposure_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. coulomb/kilogram [C/kg]: 2 | 1 3 | 2. millicoulomb/kilogram: 4 | 1000 5 | 3. microcoulomb/kilogram: 6 | 1000000 7 | 4. coulomb/gram [C/g]: 8 | 0.001 9 | 5. coulomb/milligram [C/mg]: 10 | 0.000001 11 | 6. coulomb/microgram [C/ug]: 12 | 1e-9 13 | 7. roentgen [R]: 14 | 3875.968992 15 | 9. parker: 16 | 3875.968992 17 | -------------------------------------------------------------------------------- /test/files/test_conversions/number_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. one: 2 | 1 3 | 2. dozen: 4 | 0.08333333 5 | 3. pair: 6 | 0.5 7 | 10. ten: 8 | 0.1 9 | 11. twenty: 10 | 0.05 11 | 12. fifty: 12 | 0.02 13 | 13. hundred: 14 | 0.01 15 | 14. thousand: 16 | 0.001 17 | 15. million: 18 | 0.000001 19 | 16. billion: 20 | 1e-9 21 | 17. trillion: 22 | 1e-12 23 | 22. quarter: 24 | 4 25 | 23. half: 26 | 2 -------------------------------------------------------------------------------- /.ci/azure-build.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - task: CMake@1 3 | inputs: 4 | cmakeArgs: .. -DCMAKE_CXX_STANDARD=$(units.std) -DUNITS_HEADER_ONLY=$(units.header) -DCMAKE_BUILD_TYPE=$(units.build_type) $(units.options) 5 | displayName: "Configure" 6 | env: 7 | GIT_SSL_NO_VERIFY: 1 8 | 9 | - script: cmake --build . 10 | displayName: "Build" 11 | workingDirectory: build 12 | -------------------------------------------------------------------------------- /test/files/test_conversions/mass_flux_conversions.txt: -------------------------------------------------------------------------------- 1 | gram/second/square meter: 2 | 1 3 | kilogram/hour/square meter: 4 | 3.6 5 | kilogram/hour/square foot: 6 | 0.334451 7 | kilogram/second/square meter: 8 | 0.001 9 | gram/second/square centimeter: 10 | 0.0001 11 | pound/hour/square foot: 12 | 0.737338 13 | pound/second/square foot: 14 | 0.000204816 15 | pound/minute/square foot: 16 | 0.01228896 -------------------------------------------------------------------------------- /test/files/test_conversions/conductance_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. siemens [S]: 2 | 1 3 | 2. megasiemens [MS]: 4 | 0.000001 5 | 3. kilosiemens [kS]: 6 | 0.001 7 | 4. millisiemens [mS]: 8 | 1000 9 | 5. microsiemens [uS]: 10 | 1000000 11 | 6. ampere/volt [A/V]: 12 | 1 13 | 7. mho: 14 | 1 15 | 8. gemmho: 16 | 1000000 17 | 9. micromho: 18 | 1000000 19 | 10. abmho: 20 | 1e-9 21 | 11. statmho: 22 | 8.99e+11 23 | -------------------------------------------------------------------------------- /test/files/test_conversions/typography_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. meter [m]: 2 | 1 3 | 2. decimeter [dm]: 4 | 10 5 | 3. centimeter [cm]: 6 | 100 7 | 4. millimeter [mm]: 8 | 1000 9 | 8. inch [in]: 10 | 39.370079 11 | 9. feet [ft]: 12 | 3.28084 13 | 10. pica: 14 | 236.220472 15 | 11. pica - printer: 16 | 237.106299 17 | 12. point: 18 | 2834.645669 19 | 13. point - printer: 20 | 2845.275591 21 | 15. twip: 22 | 56692.91339 -------------------------------------------------------------------------------- /test/files/test_conversions/illumination_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. lux [lx]: 2 | 1 3 | 2. meter-candle: 4 | 1 5 | 3. centimeter-candle: 6 | 0.0001 7 | 4. foot-candle: 8 | 0.09290304 9 | 6. phot [ph]: 10 | 0.0001 11 | 7. nox: 12 | 1000 13 | 8. candela steradian/square meter: 14 | 1 15 | 9. lumen/square meter [lm/m2]: 16 | 1 17 | 10. lumen/square centimeter: 18 | 0.0001 19 | 11. lumen/square foot [lm/ft2]: 20 | 0.09290304 -------------------------------------------------------------------------------- /test/test.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019-2025, 3 | Lawrence Livermore National Security, LLC; 4 | See the top-level NOTICE for additional details. All rights reserved. 5 | SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | #pragma once 8 | 9 | #include "gtest/gtest.h" 10 | 11 | namespace test { 12 | static const double tolerance = 1e-6; 13 | static const double precise_tolerance = 1e-12; 14 | } // namespace test 15 | -------------------------------------------------------------------------------- /.ci/azure-steps.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | - checkout: self 3 | fetchDepth: 50 4 | submodules: true 5 | 6 | - task: CMake@1 7 | inputs: 8 | cmakeArgs: .. -DCMAKE_BUILD_TYPE=Debug 9 | displayName: "Configure" 10 | 11 | - script: cmake --build . -j 12 | displayName: "Build" 13 | workingDirectory: build 14 | 15 | - script: ctest --output-on-failure -C Debug 16 | displayName: "Test" 17 | workingDirectory: build 18 | -------------------------------------------------------------------------------- /test/files/test_conversions/fraction_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. unit: 2 | 1 3 | 2. pair: 4 | 0.5 5 | 3. percent [%]: 6 | 100 7 | 4. permille: 8 | 1000 9 | 5. parts per million [ppm]: 10 | 1000000 11 | 6. parts per billion [ppb]: 12 | 1e+9 13 | 7. half: 14 | 2 15 | 8. one third: 16 | 3 17 | 9. one fourth: 18 | 4 19 | 10. one fifth: 20 | 5 21 | 11. one sixth: 22 | 6 23 | 13. one eighth: 24 | 8 25 | 15. one tenth: 26 | 10 27 | 9. quarter: 28 | 4 29 | 23. dozen: 30 | 0.08333333 31 | 24. gross: 32 | 0.0069444444 -------------------------------------------------------------------------------- /.ci/build_lcov.sh: -------------------------------------------------------------------------------- 1 | #!/bin/env sh 2 | # (Source me) 3 | set -evx 4 | 5 | LCOV_URL="http://ftp.de.debian.org/debian/pool/main/l/lcov/lcov_1.13.orig.tar.gz" 6 | cd "${DEPS_DIR}" 7 | 8 | if [[ ! -f "${DEPS_DIR}/lcov/bin/lcov" ]] ; then 9 | echo "Downloading lcov" 10 | mkdir -p lcov 11 | travis_retry wget --no-check-certificate --quiet -O - "${LCOV_URL}" | tar --strip-components=1 -xz -C lcov 12 | fi 13 | 14 | export PATH="${DEPS_DIR}/lcov/bin:${PATH}" 15 | cd "${TRAVIS_BUILD_DIR}" 16 | 17 | set +evx 18 | -------------------------------------------------------------------------------- /.cmake-format.json: -------------------------------------------------------------------------------- 1 | { 2 | "line_width": 88, 3 | "dangle_parens": true, 4 | "command_case": "lower", 5 | "separate_fn_name_with_space": false, 6 | "always_wrap": [], 7 | "separate_ctrl_name_with_space": false, 8 | "max_lines_hwrap": 2, 9 | "tab_size": 4, 10 | "max_subgroups_hwrap": 2, 11 | "max_pargs_hwrap": 6, 12 | "keyword_case": "upper", 13 | "enum_char": ".", 14 | "bullet_char": "*", 15 | "line_ending": "unix", 16 | "first_comment_is_literal": true, 17 | "literal_comment_pattern": "Copyright" 18 | } 19 | -------------------------------------------------------------------------------- /test/files/test_conversions/mag_field_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. ampere/meter [A/m]: 2 | 1 3 | 2. ampere/millimeter [A/mm]: 4 | 0.001 5 | 3. milliampere/meter [mA/m]: 6 | 1000 7 | 4. milliampere/millimeter: 8 | 1 9 | 5. microampere/meter [uA/m]: 10 | 1000000 11 | 6. microampere/millimeter: 12 | 1000 13 | 7. ampere/yard [A/yd]: 14 | 0.9144 15 | 8. ampere/foot [A/ft]: 16 | 0.3048 17 | 9. ampere/inch [A/in]: 18 | 0.0254 19 | 10. ampere turn/meter [At/m]: 20 | 1 21 | 11. kiloampere/meter [kA/m]: 22 | 0.001 23 | 12. oersted [Oe]: 24 | 0.01256637 25 | 26 | -------------------------------------------------------------------------------- /test/files/test_conversions/linear_mass_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. Kilogram/meter [kg/m]: 2 | 1 3 | 2. Kilogram/centimeter [kg/cm]: 4 | 0.01 5 | 3. Kilogram/millimeter [kg/mm]: 6 | 0.001 7 | 4. gram/meter [g/m]: 8 | 1000 9 | 5. gram/centimeter [g/cm]: 10 | 10 11 | 6. gram/millimeter [g/mm]: 12 | 1 13 | 7. pound/foot [lb/ft]: 14 | 0.671969 15 | 8. pound/inch [lb/in]: 16 | 0.05599741 17 | 9. pound/yard [lb/yd]: 18 | 2.015907 19 | 10. ounces/foot [oz/ft]: 20 | 10.751504 21 | 11. ounces/inch [oz/in]: 22 | 0.895959 23 | 12. ounces/yard [oz/yd]: 24 | 32.254511 -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "overrides": [ 3 | { 4 | "files": ".prettierrc", 5 | "options": { "parser": "json" } 6 | }, 7 | { 8 | "files": ".clang-format", 9 | "options": { "parser": "yaml" } 10 | }, 11 | { 12 | "files": ".clang-tidy", 13 | "options": { "parser": "yaml" } 14 | }, 15 | { 16 | "files": "test/.clang-tidy", 17 | "options": { "parser": "yaml" } 18 | }, 19 | { 20 | "files": "*.yml", 21 | "options": { "parser": "yaml", "singleQuote": true } 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "github-actions" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "weekly" 12 | -------------------------------------------------------------------------------- /.ci/make_and_test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo -en "travis_fold:start:script.build\\r" 3 | echo "Building..." 4 | STD=$1 5 | shift 6 | set -evx 7 | 8 | 9 | mkdir -p build 10 | cd build 11 | cmake .. -DCMAKE_CXX_STANDARD=$STD -DCMAKE_BUILD_TYPE=Debug $2 -DCMAKE_CXX_COMPILER_LAUNCHER=ccache $@ 12 | cmake --build . -- -j2 13 | 14 | set +evx 15 | echo -en "travis_fold:end:script.build\\r" 16 | echo -en "travis_fold:start:script.test\\r" 17 | echo "Testing..." 18 | set -evx 19 | 20 | ctest --output-on-failure 21 | 22 | set +evx 23 | echo -en "travis_fold:end:script.test\\r" 24 | -------------------------------------------------------------------------------- /python/units_llnl/__init__.py: -------------------------------------------------------------------------------- 1 | from typing import TypeAlias 2 | from .units_llnl_ext import ( 3 | Unit, 4 | Measurement, 5 | Dimension, 6 | convert, 7 | convert_pu, 8 | default_unit, 9 | add_user_defined_unit, 10 | defined_units_from_file, 11 | __doc__, 12 | ) 13 | 14 | Quantity: TypeAlias = Measurement 15 | 16 | 17 | def asdimension(arg) -> Dimension: 18 | return Dimension(arg) 19 | 20 | 21 | def asunit(*args) -> Unit: 22 | return Unit(*args) 23 | 24 | 25 | def asquantity(*args) -> Quantity: 26 | return Measurement(*args) 27 | -------------------------------------------------------------------------------- /test/pkg_test_code/main.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2020-2025, 3 | Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance 4 | for Sustainable Energy, LLC. See the top-level NOTICE for additional details. 5 | All rights reserved. SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include UNITS_LIB_HEADER 9 | 10 | #include 11 | 12 | int main(int /*argc*/, char* /*argv*/[]) 13 | { 14 | auto u1 = units::measurement_from_string("10.7 meters per second"); 15 | 16 | std::cout << to_string(u1) << std::endl; 17 | return 0; 18 | } 19 | -------------------------------------------------------------------------------- /test/files/test_conversions/charge_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. coulomb [C]: 2 | 1 3 | 2. kilocoulomb [kC]: 4 | 0.001 5 | 3. millicoulomb [mC]: 6 | 1000 7 | 4. microcoulomb [uC]: 8 | 1000000 9 | 5. nanocoulomb [nC]: 10 | 1e+9 11 | 6. picocoulomb [pC]: 12 | 1e+12 13 | 7. elementary charge [e]: 14 | 6.25e+18 15 | 11. franklin [Fr]: 16 | 2.994012e+9 17 | 12. megacoulomb [MC]: 18 | 0.000001 19 | 13. statcoulomb [stC]: 20 | 2.994012e+9 21 | 14. abcoulomb [abC]: 22 | 0.1 23 | 15. ampere-hour [A.h]: 24 | 0.0002777778 25 | 16. ampere-minute [A.min]: 26 | 0.01666667 27 | 17. ampere-second [A.s]: 28 | 1 29 | -------------------------------------------------------------------------------- /test/files/test_conversions/activity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. becquerel [Bq]: 2 | 1 3 | 2. terabecquerel [TBq]: 4 | 1e-12 5 | 3. gigabecquerel [GBq]: 6 | 1e-9 7 | 4. megabecquerel [MBq]: 8 | 0.000001 9 | 5. kilobecquerel [kBq]: 10 | 0.001 11 | 6. millibecquerel [mBq]: 12 | 1000 13 | 7. curie [Ci]: 14 | 2.702703e-11 15 | 8. kilocurie [kCi]: 16 | 2.702703e-14 17 | 9. millicurie [mCi]: 18 | 2.702703e-8 19 | 10. microcurie [uCi]: 20 | 0.000027027027 21 | 11. nanocurie [nCi]: 22 | 0.02702703 23 | 12. picocurie [pCi]: 24 | 27.027027 25 | 13. rutherford: 26 | 0.000001 27 | 14. {#}/minute: 28 | 60 29 | 30 | -------------------------------------------------------------------------------- /.ci/quick_fuzz.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo -en "travis_fold:start:script.build\\r" 3 | echo "Building..." 4 | STD=$1 5 | shift 6 | set -evx 7 | 8 | 9 | mkdir -p build 10 | cd build 11 | cmake .. -DCMAKE_CXX_STANDARD=14 -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DBUILD_UNITS_FUZZ_TARGETS=ON $@ 12 | cmake --build . -- -j2 13 | 14 | set +evx 15 | echo -en "travis_fold:end:script.build\\r" 16 | echo -en "travis_fold:start:script.test\\r" 17 | echo "Testing..." 18 | set -evx 19 | 20 | ctest --output-on-failure 21 | 22 | set +evx 23 | echo -en "travis_fold:end:script.test\\r" 24 | -------------------------------------------------------------------------------- /.ci/build_doxygen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/env sh 2 | # (Source me) 3 | 4 | set -evx 5 | 6 | DOXYGEN_URL="http://doxygen.nl/files/doxygen-1.8.15.src.tar.gz" 7 | cd "${DEPS_DIR}" 8 | 9 | if [[ ! -f "${DEPS_DIR}/doxygen/build/bin/doxygen" ]] ; then 10 | echo "Downloading Doxygen" 11 | mkdir -p doxygen 12 | travis_retry wget --no-check-certificate --quiet -O - "${DOXYGEN_URL}" | tar --strip-components=1 -xz -C doxygen 13 | cd doxygen 14 | mkdir -p build 15 | cd build 16 | cmake .. 17 | make -j2 18 | fi 19 | 20 | export PATH="${DEPS_DIR}/doxygen/build/bin:${PATH}" 21 | 22 | cd "${TRAVIS_BUILD_DIR}" 23 | 24 | set +evx 25 | -------------------------------------------------------------------------------- /config/cppcheck_suppressions.txt: -------------------------------------------------------------------------------- 1 | unusedFunction:units/x12_conv.cpp:1024 2 | unusedFunction:units/x12_conv.cpp:1009 3 | passedByValue:units/units.cpp:224 4 | passedByValue:units/units.cpp:1160 5 | passedByValue:units/units.cpp:1177 6 | passedByValue:units/units.cpp:3069 7 | passedByValue:units/units.hpp:413 8 | passedByValue:units/units.hpp:590 9 | passedByValue:units/units.hpp:1020 10 | passedByValue:units/units.hpp:1032 11 | returnByReference:units/units.hpp:363 12 | returnByReference:units/units.hpp:576 13 | returnByReference:units/units.hpp:1017 14 | returnByReference:units/units.hpp:1246 15 | returnByReference:units/units.hpp:1485 16 | -------------------------------------------------------------------------------- /.github/workflows/arm_mac_gcc.yml: -------------------------------------------------------------------------------- 1 | name: ARM GCC 2 | on: 3 | pull_request: 4 | branches: 5 | - main 6 | 7 | jobs: 8 | arm64_gcc: 9 | name: ARM64 GCC 10 | runs-on: ubuntu-24.04-arm 11 | steps: 12 | - uses: actions/checkout@v6 13 | 14 | - name: Configure 15 | run: | 16 | cmake -S . -B build \ 17 | -DCMAKE_CXX_STANDARD=20 \ 18 | -DUNITS_ENABLE_TESTS=ON \ 19 | -DUNITS_DISABLE_EXTRA_UNIT_STANDARDS=ON 20 | 21 | - name: Build 22 | run: cmake --build build -j4 23 | 24 | - name: Test 25 | run: | 26 | cd build 27 | ctest --output-on-failure -------------------------------------------------------------------------------- /test/files/test_conversions/heat_transfer_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. watt/square meter/K [W/(m2.K)]: 2 | 1 3 | 2. watt/square meter/degC [W/(m2.oC)]: 4 | 1 5 | 3. joule/second/square meter/K: 6 | 1 7 | 4. calorie (IT)/second/square centimeter/degC: 8 | 0.000023885 9 | 5. kilocalorie (IT)/hour/square meter/degC: 10 | 0.859845 11 | 6. kilocalorie (IT)/hour/square foot/degC: 12 | 0.07988224 13 | 7. Btu (IT)/second/square foot/degF: 14 | 0.000048919 15 | 8. Btu (th)/second/square foot/oF: 16 | 0.000048952 17 | 9. Btu (IT)/hour/square foot/oF: 18 | 0.17611 19 | 10. Btu (th)/hour/square foot/degF: 20 | 0.176228 21 | 11. CHU/hour/square foot/degC: 22 | 0.17611 -------------------------------------------------------------------------------- /docs/details/string_parsing_squared.rst: -------------------------------------------------------------------------------- 1 | ============================== 2 | Parsing of squared and cubic 3 | ============================== 4 | 5 | When units are written there are a few terms that modify the powers of a unit. 6 | The two primary terms are `square` and `cubic` 7 | 8 | These are rules the library follows when parsing terms such as this 9 | 10 | - `square` or `sq` or `sq.` will apply to the unit immediately following the term 11 | - `cubic` or `cu` or `cu.` will apply the unit immediately following the term 12 | - `squared` will apply to the unit immediately preceding the term 13 | - `cubed` will apply to the unit immediately preceding the term 14 | -------------------------------------------------------------------------------- /test/files/test_conversions/current_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. ampere [A]: 2 | 1 3 | 2. kiloampere [kA]: 4 | 0.001 5 | 3. deciampere [dA]: 6 | 10 7 | 4. centiampere [cA]: 8 | 100 9 | 5. milliampere [mA]: 10 | 1000 11 | 6. microampere [uA]: 12 | 1000000 13 | 7. dekaampere: 14 | 0.1 15 | 8. hectoampere: 16 | 0.01 17 | 9. megaampere [MA]: 18 | 0.000001 19 | 10. biot [Bi]: 20 | 0.1 21 | 11. gilbert: 22 | 1.256637 23 | 12. abampere [abA]: 24 | 0.1 25 | 14. statampere [stA]: 26 | 2.997925e+9 27 | 18. volt/ohm: 28 | 1 29 | 19. watt/volt: 30 | 1 31 | 20. weber/henry: 32 | 1 33 | 21. siemens volt: 34 | 1 35 | 22. coulomb/second [C/s]: 36 | 1 37 | 23. franklin/second [Fr/s]: 38 | 2.994012e+9 -------------------------------------------------------------------------------- /.ci/check_tidy.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | echo -en "travis_fold:start:script.build\\r" 4 | echo "Building with tidy on..." 5 | set -evx 6 | 7 | mkdir -p build-tidy 8 | cd build-tidy 9 | CXX_FLAGS="-Werror -Wcast-align -Wfloat-equal -Wimplicit-atomic-properties -Wmissing-declarations -Woverlength-strings -Wshadow -Wstrict-selector-match -Wundeclared-selector -Wunreachable-code -std=c++11" cmake .. -DCLANG_TIDY_FIX=ON 10 | cmake --build . 11 | 12 | set -evx 13 | echo -en "travis_fold:end:script.build\\r" 14 | echo -en "travis_fold:start:script.compare\\r" 15 | echo "Checking git diff..." 16 | set -evx 17 | 18 | git diff --exit-code --color 19 | 20 | set +evx 21 | echo -en "travis_fold:end:script.compare\\r" 22 | -------------------------------------------------------------------------------- /test/pkg_test_code/header_only.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019-2025, 3 | Battelle Memorial Institute; Lawrence Livermore National Security, LLC; Alliance 4 | for Sustainable Energy, LLC. See the top-level NOTICE for additional details. 5 | All rights reserved. SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include UNITS_LIB_HEADER 9 | 10 | #include 11 | 12 | int main() 13 | { 14 | using namespace units; 15 | units::measurement b(50.0, m); 16 | units::measurement c(25.0, ft); 17 | auto k = b * c; 18 | 19 | if (k.units().has_same_base(m.pow(2))) { 20 | std::cout << "PASS\n"; 21 | } else { 22 | std::cout << "FAILE\n"; 23 | } 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /test/files/test_conversions/inductance_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. henry [H]: 2 | 1 3 | 2. exahenry [EH]: 4 | 1e-18 5 | 3. petahenry [PH]: 6 | 1e-15 7 | 4. terahenry [TH]: 8 | 1e-12 9 | 5. gigahenry [GH]: 10 | 1e-9 11 | 6. megahenry [MH]: 12 | 0.000001 13 | 7. kilohenry [kH]: 14 | 0.001 15 | 8. hectohenry [hH]: 16 | 0.01 17 | 9. dekahenry [daH]: 18 | 0.1 19 | 10. decihenry [dH]: 20 | 10 21 | 11. centihenry [cH]: 22 | 100 23 | 12. millihenry [mH]: 24 | 1000 25 | 13. microhenry [uH]: 26 | 1000000 27 | 14. nanohenry [nH]: 28 | 1e+9 29 | 15. picohenry: 30 | 1e+12 31 | 16. femtohenry [fH]: 32 | 1e+15 33 | 17. attohenry [aH]: 34 | 1e+18 35 | 18. weber/ampere [Wb/A]: 36 | 1 37 | 19. abhenry [abH]: 38 | 1e+9 39 | 21. stathenry [stH]: 40 | 1.11e-12 -------------------------------------------------------------------------------- /test/files/test_conversions/capacitance_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. farad [F]: 2 | 1 3 | 2. exafarad [EF]: 4 | 1e-18 5 | 3. petafarad [PF]: 6 | 1e-15 7 | 4. terafarad [TF]: 8 | 1e-12 9 | 5. gigafarad : 10 | 1e-9 11 | 6. megafarad [MF]: 12 | 0.000001 13 | 7. kilofarad [kF]: 14 | 0.001 15 | 8. hectofarad [hF]: 16 | 0.01 17 | 9. dekafarad [daF]: 18 | 0.1 19 | 10. decifarad [dF]: 20 | 10 21 | 11. centifarad [cF]: 22 | 100 23 | 12. millifarad [mF]: 24 | 1000 25 | 13. microfarad [uF]: 26 | 1000000 27 | 14. nanofarad [nF]: 28 | 1e+9 29 | 15. picofarad [pF]: 30 | 1e+12 31 | 16. femtofarad [fF]: 32 | 1e+15 33 | 17. attofarad [aF]: 34 | 1e+18 35 | 18. coulomb/volt [C/V]: 36 | 1 37 | 19. abfarad [abF]: 38 | 1e-9 39 | 21. statfarad [stF]: 40 | 8.99e+11 -------------------------------------------------------------------------------- /test/files/test_conversions/luminance_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. candela/square meter: 2 | 1 3 | 2. candela/square centimeter: 4 | 0.0001 5 | 3. kilocandela/square meter: 6 | 0.001 7 | 4. stilb [sb]: 8 | 0.0001 9 | 5. lumen/square meter/steradian: 10 | 1 11 | 6. lumen/square centimeter/steradian: 12 | 0.0001 13 | 8. nit [nt]: 14 | 1 15 | 9. millinit [mnt]: 16 | 1000 17 | 10. lambert: 18 | 0.000314159 19 | 11. millilambert : 20 | 0.314159 21 | 12. foot-lambert [fl]: 22 | 0.291864 23 | 13. apostilb: 24 | 3.14159 25 | 14. blondel: 26 | 3.14159 27 | 15. bril: 28 | 31415900 29 | 16. skot: 30 | 3141.59 31 | 17. lumen/square foot/steradian: 32 | 0.09290304 33 | 18. candela/square foot [cd/ft2]: 34 | 0.09290304 35 | 19. candela/square inch [cd/in2]: 36 | 0.00064516 -------------------------------------------------------------------------------- /.ci/azure-cmake.yml: -------------------------------------------------------------------------------- 1 | steps: 2 | # Note that silkeh/clang does not include ca-certificates, so check the shasum for verification 3 | - bash: | 4 | wget --no-check-certificate "https://cmake.org/files/v3.14/cmake-3.14.3-Linux-x86_64.tar.gz" 5 | echo "29faa62fb3a0b6323caa3d9557e1a5f1205614c0d4c5c2a9917f16a74f7eff68 cmake-3.14.3-Linux-x86_64.tar.gz" | shasum -sca 256 6 | displayName: Download CMake 7 | 8 | - task: ExtractFiles@1 9 | inputs: 10 | archiveFilePatterns: "cmake*.tar.gz" 11 | destinationFolder: "cmake_program" 12 | displayName: Extract CMake 13 | 14 | - bash: echo "##vso[task.prependpath]$(Build.SourcesDirectory)/cmake_program/cmake-3.14.3-Linux-x86_64/bin" 15 | displayName: Add CMake to PATH 16 | -------------------------------------------------------------------------------- /.github/actions/quick_cmake/action.yml: -------------------------------------------------------------------------------- 1 | name: Quick CMake config 2 | description: 'Runs CMake 3.4+ (if already setup)' 3 | inputs: 4 | args: 5 | description: 'Other arguments' 6 | required: false 7 | default: '' 8 | cmake-version: 9 | description: 'The CMake version to run' 10 | required: true 11 | 12 | runs: 13 | using: composite 14 | steps: 15 | - name: CMake ${{ inputs.cmake-version }} 16 | uses: jwlawson/actions-setup-cmake@v1.13 17 | with: 18 | cmake-version: "${{ inputs.cmake-version }}" 19 | - run: | 20 | mkdir -p build-tmp 21 | touch build-tmp/tmp 22 | rm -r build-tmp/* 23 | (cd build-tmp && cmake .. ${{ inputs.args }}) 24 | rm -r build-tmp 25 | shell: bash 26 | -------------------------------------------------------------------------------- /.codecov.yml: -------------------------------------------------------------------------------- 1 | codecov: 2 | notify: 3 | require_ci_to_pass: no 4 | after_n_builds: 4 5 | branch: main 6 | 7 | coverage: 8 | precision: 2 9 | round: down 10 | range: '95...100' 11 | status: 12 | project: 13 | default: 14 | # basic 15 | target: 100% 16 | threshold: 0% 17 | base: auto 18 | patch: yes 19 | changes: no 20 | 21 | parsers: 22 | gcov: 23 | branch_detection: 24 | conditional: yes 25 | loop: yes 26 | method: no 27 | macro: no 28 | 29 | comment: 30 | layout: 'header, diff' 31 | behavior: default 32 | require_changes: no 33 | 34 | ignore: 35 | - 'ThirdParty' 36 | - 'examples' 37 | - 'test' 38 | - 'FuzzTargets' 39 | - 'webserver' 40 | - 'converter' 41 | -------------------------------------------------------------------------------- /.github/workflows/freebsd.yml: -------------------------------------------------------------------------------- 1 | name: freebsd 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | 9 | jobs: 10 | test: 11 | runs-on: ubuntu-latest 12 | name: run test on FreeBSD 13 | steps: 14 | - uses: actions/checkout@v6 15 | - name: Test in FreeBSD 16 | id: test 17 | uses: vmactions/freebsd-vm@v1 18 | with: 19 | usesh: true 20 | prepare: | 21 | pkg install -y devel/googletest cmake pkgconf 22 | 23 | run: | 24 | cmake -S . -B build \ 25 | -DCMAKE_CXX_STANDARD=17 \ 26 | -DUNITS_ENABLE_TESTS=ON \ 27 | -DUNITS_USE_EXTERNAL_GTEST=ON 28 | cmake --build build -j4 29 | cd build 30 | ctest --output-on-failure -------------------------------------------------------------------------------- /test/files/test_conversions/thermal_conductivity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. watt/meter/K [W/(m.K)]: 2 | 1 3 | 2. watt/centimeter/degC [W/(cm.oC)]: 4 | 0.01 5 | 3. kilowatt/meter/K [kW/(m.K)]: 6 | 0.001 7 | 4. calorie (IT)/second/centimeter/degC: 8 | 0.002388459 9 | 5. calorie (th)/second/centimeter/oC: 10 | 0.002390057 11 | 6. kilocalorie (IT)/hour/meter/degC: 12 | 0.859845 13 | 7. kilocalorie (th)/hour/meter/degC: 14 | 0.860421 15 | 8. Btu (IT) inch/second/square foot/degF: 16 | 0.001925964 17 | 9. Btu (th) inch/second/square foot/degF: 18 | 0.001927253 19 | 10. Btu (IT) foot/hour/square foot/degF: 20 | 0.577789 21 | 11. Btu (th) foot/hour/square foot/degF: 22 | 0.578176 23 | 12. Btu (IT) inch/hour/square foot/oF: 24 | 6.933472 25 | 13. Btu (th) inch/hour/square foot/degF: 26 | 6.938112 -------------------------------------------------------------------------------- /FuzzTargets/fuzz_script.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | mkdir -p /fuzz/corpus 4 | mkdir -p /fuzz/logs 5 | 6 | # run the first fuzzing sequence 7 | ./fuzz_measurement /fuzz/corpus -max_len=512 -dict=/root/develop/fuzz_targets/fuzz_dictionary.txt -rss_limit_mb=512 -max_total_time=1390 -timeout=20 -artifact_prefix=/fuzz/ &> fuzzlog.txt 8 | 9 | #if we haven't failed merge the corpus so it is smaller 10 | if [ $? -eq 0 ] 11 | then 12 | mkdir -p new_corpus 13 | ./fuzz_measurement new_corpus /fuzz/corpus -merge=1 -max_len=512 -max_total_time=120 &>"/fuzz/logs/fuzz_merge$(date +"%s").log" 14 | if [ $? -eq 0 ] 15 | then 16 | rm /fuzz/corpus/* 17 | mv new_corpus/* /fuzz/corpus/ 18 | fi 19 | else 20 | tail --lines=500 fuzzlog.txt >"/fuzz/logs/fuzz_crash$(date +"%s").log" 21 | fi 22 | -------------------------------------------------------------------------------- /.github/workflows/static-analyzers.yml: -------------------------------------------------------------------------------- 1 | name: Static Analyzers 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | pull_request: 8 | branches: 9 | - main 10 | 11 | jobs: 12 | cpplint: 13 | runs-on: ubuntu-latest 14 | container: helics/buildenv:cpplint 15 | 16 | steps: 17 | - uses: actions/checkout@v6 18 | - name: Run cpplint 19 | run: cpplint --counting=detailed --recursive units test webserver converter 20 | cppcheck: 21 | runs-on: ubuntu-latest 22 | container: helics/buildenv:cppcheck2 23 | 24 | steps: 25 | - uses: actions/checkout@v6 26 | - name: Run cppcheck 27 | run: cppcheck --enable=performance,portability --check-level=exhaustive --suppressions-list=config/cppcheck_suppressions.txt --error-exitcode=-4 -i ThirdParty -i FuzzTargets -i docs -i config . -------------------------------------------------------------------------------- /test/files/test_conversions/fuel_consumption_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. meter/liter [m/L]: 2 | 14454.885028 3 | 2. kilometer/liter [km/L]: 4 | 14.454885 5 | 3. nautical mile/liter [nmi/L]: 6 | 7.805014 7 | 4. meter/cubic meter [m/m3]: 8 | 14454885.028395 9 | 5. meter/cubic yard [m/yd3]: 10 | 11051552.57006 11 | 6. meter/cubic foot [m/ft3]: 12 | 409316.761854 13 | 7. meter/cubic inch [m/in3]: 14 | 236.873126 15 | 8. mile/liter [mi/L]: 16 | 8.981846 17 | 9. mile/gallon (US) [mi/gal (US)]: 18 | 34 19 | 10. mile/gallon (UK) [mi/gal (UK)]: 20 | 40.832289 21 | 11. nautical mile/gallon (UK): 22 | 35.482366 23 | 12. kilometer/gallon (UK): 24 | 65.713343 25 | 13. meter/gallon (US) [m/gal (US)]: 26 | 54717.692108 27 | 14. meter/quart (US) [m/qt (US)]: 28 | 13679.423 29 | 15. meter/gallon (UK) [m/gal (UK)]: 30 | 65713.342622 31 | 16. meter/quart (UK) [m/qt (UK)]: 32 | 16428.335656 -------------------------------------------------------------------------------- /CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | set noparent 2 | linelength=100 # As in .clang-format 3 | 4 | # Non-used filters 5 | filter=-build/include_order # Requires unusual include order that encourages creating not self-contained headers 6 | filter=-build/include_subdir # this is generally good but causes some issues 7 | filter=-readability/nolint # Conflicts with clang-tidy 8 | filter=-runtime/references # Requires fundamental change of API, don't see need for this 9 | filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability 10 | filter=-whitespace/indent # Requires strange 3-space indent of private/protected/public markers 11 | filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format 12 | filter=-runtime/indentation_namespace #conflicts with clang format 13 | filter=-runtime/explicit #issues caught by clang-tidy 14 | -------------------------------------------------------------------------------- /test/files/test_conversions/mag_flux_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. weber [Wb]: 2 | 1 3 | 2. milliweber [mWb]: 4 | 1000 5 | 3. microweber [uWb]: 6 | 1000000 7 | 4. kiloweber [kWb]: 8 | 0.001 9 | 5. megaweber [MWb]: 10 | 0.000001 11 | 6. volt second [V.s]: 12 | 1 13 | 7. unit pole: 14 | 7957747.155 15 | 8. megamaxwell: 16 | 100 17 | 9. kilomaxwell: 18 | 100000 19 | 11. maxwell [Mx]: 20 | 100000000 21 | 13. tesla square meter [T.m2]: 22 | 1 23 | 14. tesla square centimeter: 24 | 10000 25 | 15. tesla square micrometer: 26 | 1e12 27 | 16. gauss square meter: 28 | 10000 29 | 17. gauss square centimeter: 30 | 100000000 31 | 18. Gauss square yard: 32 | 11959.900463 33 | 19. Gauss square foot: 34 | 107639.104167 35 | 20. Gauss square inch: 36 | 15500031 37 | 21. tesla square yard [T.yd2]: 38 | 1.19599 39 | 22. tesla square foot [T.ft2]: 40 | 10.76391 41 | 23. tesla square inch [T.in2]: 42 | 1550.0031 -------------------------------------------------------------------------------- /test/files/test_conversions/dose_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. RAD: 2 | 1 3 | 2. milliRAD [mRAD]: 4 | 1000 5 | 3. microRAD [uRAD]: 6 | 1000000 7 | 4. joule/kilogram [J/kg]: 8 | 0.01 9 | 5. joule/gram [J/g]: 10 | 0.00001 11 | 6. joule/centigram [J/cg]: 12 | 1e-7 13 | 7. joule/milligram [J/mg]: 14 | 1e-8 15 | 8. gray [Gy]: 16 | 0.01 17 | 9. exagray [Egy]: 18 | 1e-20 19 | 10. petagray [Pgy]: 20 | 1e-17 21 | 11. teragray [Tgy]: 22 | 1e-14 23 | 12. gigagray [Ggy]: 24 | 1e-11 25 | 13. megagray [Mgy]: 26 | 1e-8 27 | 14. kilogray [kGy]: 28 | 0.00001 29 | 15. hectogray [hGy]: 30 | 0.0001 31 | 16. dekagray [daGy]: 32 | 0.001 33 | 17. decigray [dGy]: 34 | 0.1 35 | 18. centigray [cGy]: 36 | 1 37 | 19. milligray [mGy]: 38 | 10 39 | 20. microgray [uGy]: 40 | 10000 41 | 21. nanogray [nGy]: 42 | 10000000 43 | 22. picogray [pGy]: 44 | 1e+10 45 | 23. femtogray [fGy]: 46 | 1e+13 47 | 24. attogray [aGy]: 48 | 1e+16 -------------------------------------------------------------------------------- /test/files/test_conversions/concentration_ratio_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. percentage: 2 | 1 3 | 2. part per million [ppm]: 4 | 10000 5 | 3. part per billion [ppb]: 6 | 10000000 7 | 4. part per trillion [ppt]: 8 | 1e+10 9 | 5. part per quadrillion: 10 | 1e+13 11 | 6. gram/kilogram [g/kg]: 12 | 10 13 | 7. microgram/gram [ug/g]: 14 | 10000 15 | 8. nanogram/microgram [ng/ug]: 16 | 10 17 | 9. nanogram/gram [ng/g]: 18 | 10000000 19 | 10. nanogram/kilogram [ng/kg]: 20 | 1e+10 21 | 11. milligram/kilogram [mg/kg]: 22 | 10000 23 | 12. milligram/gram [mg/g]: 24 | 10 25 | 14. microgram/kilogram [ug/kg]: 26 | 10000000 27 | 15. microliter/liter [ul/l]: 28 | 10000 29 | 16. nanoliter/microliter: 30 | 10 31 | 17. milliliter/m3 [ml/m3]: 32 | 10000 33 | 18. milliliter/liter [ml/l]: 34 | 10 35 | 19. microliter/m3 [ul/m3]: 36 | 10000000 37 | 20. microgram/milligram [ug/mg]: 38 | 10 39 | 21. gram/tonne [g/t]: 40 | 10000 -------------------------------------------------------------------------------- /config/unitsConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # - Config file for the units package 2 | # It defines the following variables 3 | # UNITS_INCLUDE_DIRS - include directories for units library 4 | # UNITS_LIBRARIES - libraries to link against 5 | # UNITS_WEBSERVER - the units webserver executable 6 | # UNITS_CONVERT - the units conversion utility 7 | 8 | # Compute paths 9 | get_filename_component(UNITS_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 10 | set(UNITS_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") 11 | 12 | # Our library dependencies (contains definitions for IMPORTED targets) 13 | if(NOT TARGET units::units AND NOT units_BINARY_DIR) 14 | include("${UNITS_CMAKE_DIR}/unitsTargets.cmake") 15 | endif() 16 | 17 | # These are IMPORTED targets created by FooBarTargets.cmake 18 | set(UNITS_LIBRARIES units::units) 19 | set(UNITS_WEBSERVER units::units_webserver) 20 | set(UNITS_CONVERT units::units_convert) 21 | -------------------------------------------------------------------------------- /ThirdParty/cmake/Utils.cmake: -------------------------------------------------------------------------------- 1 | # returns true if only a single one of its arguments is true 2 | function(xor result) 3 | set(true_args_count 0) 4 | 5 | foreach(foo ${ARGN}) 6 | if(foo) 7 | math(EXPR true_args_count "${true_args_count}+1") 8 | endif() 9 | endforeach() 10 | 11 | if(NOT (${true_args_count} EQUAL 1)) 12 | set(${result} FALSE PARENT_SCOPE) 13 | else() 14 | set(${result} TRUE PARENT_SCOPE) 15 | endif() 16 | endfunction() 17 | 18 | function(at_most_one result) 19 | set(true_args_count 0) 20 | 21 | foreach(foo ${ARGN}) 22 | if(foo) 23 | math(EXPR true_args_count "${true_args_count}+1") 24 | endif() 25 | endforeach() 26 | 27 | if(${true_args_count} GREATER 1) 28 | set(${result} FALSE PARENT_SCOPE) 29 | else() 30 | set(${result} TRUE PARENT_SCOPE) 31 | endif() 32 | endfunction() 33 | -------------------------------------------------------------------------------- /test/files/test_conversions/enzyme_activity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. katal [kat]: 2 | 1 3 | 2. dkatal [dkat]: 4 | 10 5 | 3. centikatal [ckat]: 6 | 100 7 | 4. millikatal [mkat]: 8 | 1000 9 | 5. microkatal [ukat]: 10 | 1000000 11 | 6. nanokatal [nkat]: 12 | 1e+9 13 | 7. picokatal [pkat]: 14 | 1e+12 15 | 8. femtokatal [fkat]: 16 | 1e+15 17 | 9. attokatal [akat]: 18 | 1e+18 19 | 10. zeptokatal [zkat]: 20 | 1e+21 21 | 11. yoctokatal [ykat]: 22 | 1e+24 23 | 12. decakatal [dakat]: 24 | 0.1 25 | 13. hectokatal [hkat]: 26 | 0.01 27 | 14. kilokatal [kkat]: 28 | 0.001 29 | 15. megakatal [Mkat]: 30 | 0.000001 31 | 16. gigakatal [Gkat]: 32 | 1e-9 33 | 17. mole/second [mol/s]: 34 | 1 35 | 18. millimole/second [mmol/s]: 36 | 1000 37 | 19. kilomole/second [kmol/s]: 38 | 0.001 39 | 20. micromole/s [umol/s]: 40 | 1000000 41 | 21. mole/minute [mol/min]: 42 | 60 43 | 22. micromole/min [umol/min]: 44 | 60000000 45 | 23. millimole/min [mmol/min]: 46 | 60000 -------------------------------------------------------------------------------- /docs/user-guide/index.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | User Guide 3 | ============ 4 | 5 | The Units library user guide is an in depth look at how to use the C++ library and its functionality, covering the basic types in the library and operations with them. 6 | The guide covers the basic types and what operations are available on them, as well as a lot of details on how to use the library. 7 | 8 | The python package is a simplified wrapper around the C++ library and is discussed in :ref:`python` 9 | 10 | .. toctree:: 11 | :maxdepth: 1 12 | 13 | units 14 | measurements 15 | fixed_measurements 16 | uncertain_measurements 17 | from_string 18 | to_string 19 | math_operations 20 | commodities 21 | user_defined_units 22 | Physical_constants 23 | defined_units 24 | custom_units 25 | custom_count_units 26 | Unit_domains 27 | conversion_flags 28 | special_units 29 | equation_units 30 | python 31 | -------------------------------------------------------------------------------- /test/files/test_conversions/time_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. second [s]: 2 | 1 3 | 2. millisecond [ms]: 4 | 1000 5 | 3. microsecond [us]: 6 | 1000000 7 | 4. nanosecond [ns]: 8 | 1e+9 9 | 5. picosecond [ps]: 10 | 1e+12 11 | 6. femtosecond [fs]: 12 | 1e+15 13 | 7. attosecond: 14 | 1e+18 15 | 8. shake: 16 | 100000000 17 | 9. minute [min]: 18 | 0.01666667 19 | 10. hour [h]: 20 | 0.0002777778 21 | 11. day [d]: 22 | 0.000011574074 23 | 12. week: 24 | 0.000001653439 25 | 13. month: 26 | 3.805175e-7 27 | 14. month (synodic): 28 | 3.919349e-7 29 | 15. year [y]: 30 | 3.170979e-8 31 | 16. year (Julian): 32 | 3.168809e-8 33 | 17. year (leap): 34 | 3.162315e-8 35 | 18. year (tropical): 36 | 3.168876e-8 37 | 19. year (sidereal): 38 | 3.168754e-8 39 | 20. day (sidereal): 40 | 0.000011605763 41 | 24. fortnight: 42 | 8.267196e-7 43 | 25. decade: 44 | 3.170979e-9 45 | 27. century: 46 | 3.170979e-10 47 | 28. millennium: 48 | 3.174603e-11 49 | 34. Planck time: 50 | 1.86e+43 -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /ThirdParty/cmake/extraMacros.cmake: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------- 2 | # MACRO definitions 3 | # ------------------------------------------------------------- 4 | 5 | # Macros to hide/show cached variables. These two macros can be used to "hide" 6 | # or "show" in the list of cached variables various variables and/or options 7 | # that depend on other options. Note that once a variable is modified, it will 8 | # preserve its value (hiding it merely makes it internal) 9 | 10 | macro(HIDE_VARIABLE var) 11 | if(DEFINED ${var}) 12 | set(${var} "${${var}}" CACHE INTERNAL "") 13 | endif(DEFINED ${var}) 14 | endmacro(HIDE_VARIABLE) 15 | 16 | macro(SHOW_VARIABLE var type doc default) 17 | if(DEFINED ${var}) 18 | set(${var} "${${var}}" CACHE "${type}" "${doc}" FORCE) 19 | else(DEFINED ${var}) 20 | set(${var} "${default}" CACHE "${type}" "${doc}") 21 | endif(DEFINED ${var}) 22 | endmacro(SHOW_VARIABLE) 23 | -------------------------------------------------------------------------------- /webserver/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | set noparent 2 | linelength=80 # As in .clang-format 3 | 4 | # Non-used filters 5 | filter=-build/c++11 # Reports e.g. chrono and thread, which overlap with Chromium's API. Not applicable to general C++ projects. 6 | filter=-build/include_order # Requires unusual include order that encourages creating not self-contained headers 7 | filter=-readability/nolint # Conflicts with clang-tidy 8 | filter=-runtime/references # Requires fundamental change of API, don't see need for this 9 | filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability 10 | filter=-whitespace/indent # Requires strange 3-space indent of private/protected/public markers 11 | filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format 12 | filter=-build/namespaces # tests would be a lot messier without this 13 | filter=-runtime/indentation_namespace #conflicts with clang format 14 | filter=-runtime/explicit #issues caught by clang-tidy 15 | -------------------------------------------------------------------------------- /webserver/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM helics/buildenv:gcc12-builder as builder 2 | 3 | WORKDIR /root/develop 4 | 5 | RUN git clone https://github.com/LLNL/units.git units 6 | 7 | WORKDIR /root/develop/build 8 | 9 | RUN cmake ../units -DUNITS_BUILD_WEBSERVER=ON -DBUILD_TESTING=OFF -DCMAKE_CXX_STANDARD=17 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON && make -j2 10 | 11 | WORKDIR /root/develop/webserver 12 | 13 | RUN cp ../build/bin/units_webserver . && cp ../units/webserver/*.html . && cp ../units/webserver/*.sh . 14 | 15 | FROM ubuntu:22.04 16 | 17 | COPY --from=builder /root/develop/webserver /root/develop/webserver 18 | 19 | ARG GIT_COMMIT=unspecified 20 | 21 | LABEL maintainer="top1@llnl.gov" 22 | 23 | LABEL name="units.webserver" 24 | LABEL description="Units library webserver" 25 | LABEL vcs-ref=$GIT_COMMIT 26 | LABEL vcs-url="https://github.com/LLNL/units" 27 | LABEL version="0.9.1" 28 | LABEL date="2023-09-01" 29 | 30 | VOLUME /weblog 31 | 32 | WORKDIR /root/develop/webserver 33 | 34 | EXPOSE 80/tcp 35 | 36 | CMD ["./web_script.sh"] 37 | -------------------------------------------------------------------------------- /docs/user-guide/special_units.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Special Units 3 | ================== 4 | 5 | There are a few defined units that are special in some fashion, and can be used as sentinel values or have special operations associated with them. 6 | 7 | Default Unit 8 | ------------- 9 | 10 | The `defunit` unit is allowed to be converted to any other unit. it is equivalent of `per-unit*i_flag` The main use case is in the convert functions and makes a good 11 | 12 | 13 | Error Unit 14 | ----------- 15 | 16 | .. code-block:: c++ 17 | 18 | auto error_unit=unit(detail::unit_data(nullptr)); 19 | 20 | Invalid Unit 21 | ------------- 22 | 23 | An invalid unit is any unit that is either the error unit or has a NaN in the multiplier. This is the unit returned from a string conversion if the string does not describe a unit or measurement. 24 | 25 | one 26 | ------ 27 | 28 | The default constructor for `unit` and `precise_unit` is empty unit data and 1.0 in the multiplier. 29 | 30 | 31 | There are also precise versions of these values in the `precise` namespace 32 | -------------------------------------------------------------------------------- /test/CPPLINT.cfg: -------------------------------------------------------------------------------- 1 | set noparent 2 | linelength=80 # As in .clang-format 3 | 4 | # Non-used filters 5 | filter=-build/c++11 # Reports e.g. chrono and thread, which overlap with Chromium's API. Not applicable to general C++ projects. 6 | filter=-build/include_order # Requires unusual include order that encourages creating not self-contained headers 7 | filter=-build/include_subdir # this is generally good but causes some issues 8 | filter=-readability/nolint # Conflicts with clang-tidy 9 | filter=-runtime/references # Requires fundamental change of API, don't see need for this 10 | filter=-whitespace/blank_line # Unnecessarily strict with blank lines that otherwise help with readability 11 | filter=-whitespace/indent # Requires strange 3-space indent of private/protected/public markers 12 | filter=-whitespace/parens,-whitespace/braces # Conflict with clang-format 13 | filter=-build/namespaces # tests would be a lot messier without this 14 | filter=-runtime/indentation_namespace #conflicts with clang format 15 | filter=-runtime/explicit #issues caught by clang-tidy 16 | -------------------------------------------------------------------------------- /test/test_all_unit_base.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019-2025, 3 | Lawrence Livermore National Security, LLC; 4 | See the top-level NOTICE for additional details. All rights reserved. 5 | SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include "test.hpp" 9 | #include "units/units.hpp" 10 | 11 | #include 12 | #include 13 | using namespace units; 14 | 15 | TEST(allUnits, all) 16 | { 17 | // this type difference is on purpose 18 | for (std::uint64_t ii = 0; ii <= std::numeric_limits::max(); 19 | ++ii) { 20 | detail::unit_data unitdata(nullptr); 21 | auto data = static_cast(ii & 0xFFFFFFFF); 22 | memcpy(static_cast(&unitdata), &data, 4); 23 | auto startunit = unit(unitdata); 24 | auto str = to_string(startunit); 25 | auto resunit = unit_cast_from_string(str); 26 | EXPECT_EQ(startunit, resunit) << "round trip failed " << data; 27 | if (data % 0xFFFFFF == 1) { 28 | std::cout << static_cast(ii >> 24) / 256.0 29 | << "% complete\n"; 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /test/files/test_conversions/kinematic_viscosity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. square meter/second [m2/s]: 2 | 1 3 | 2. square centimeter/second: 4 | 10000 5 | 3. square millimeter/second: 6 | 1000000 7 | 4. square micrometer/second: 8 | 1e+12 9 | 5. square meter/minute [m2/min]: 10 | 60 11 | 6. square meter/hour [m2/h]: 12 | 3600 13 | 7. stokes [St]: 14 | 10000 15 | 8. exastokes [ESt]: 16 | 1e-14 17 | 9. petastokes [PSt]: 18 | 1e-11 19 | 10. terastokes [TSt]: 20 | 1e-8 21 | 11. gigastokes [GSt]: 22 | 0.00001 23 | 12. megastokes [MSt]: 24 | 0.01 25 | 13. kilostokes [kSt]: 26 | 10 27 | 14. hectostokes [hSt]: 28 | 100 29 | 15. dekastokes [daSt]: 30 | 1000 31 | 16. decistokes [dSt]: 32 | 100000 33 | 17. centistokes [cSt]: 34 | 1000000 35 | 18. millistokes [mSt]: 36 | 10000000 37 | 19. microstokes [uSt]: 38 | 1e+10 39 | 20. nanostokes [nSt]: 40 | 1e+13 41 | 21. picostokes [pSt]: 42 | 1e+16 43 | 22. femtostokes [fSt]: 44 | 1e+19 45 | 23. attostokes [aSt]: 46 | 1e+22 47 | 24. square foot/second [ft2/s]: 48 | 10.76391 49 | 25. square foot/hour [ft2/h]: 50 | 38750.077512 51 | 26. square foot/minute [ft2/min]: 52 | 645.834625 53 | 27. square inch/second [in2/s]: 54 | 1550.0031 55 | 28. square yard/second [yd2/s]: 56 | 1.19599 -------------------------------------------------------------------------------- /test/files/test_conversions/viscosity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. pascal second [Pa.s]: 2 | 1 3 | 2. kilogram-force second/square meter: 4 | 0.101972 5 | 3. newton second/square meter: 6 | 1 7 | 4. millinewton second/square meter: 8 | 1000 9 | 5. dyne second/square centimeter: 10 | 10 11 | 6. poise [P]: 12 | 10 13 | 7. exapoise [EP]: 14 | 1e-17 15 | 8. petapoise [PP]: 16 | 1e-14 17 | 9. terapoise [TP]: 18 | 1e-11 19 | 10. gigapoise [GP]: 20 | 1e-8 21 | 11. megapoise [MP]: 22 | 0.00001 23 | 12. kilopoise [kP]: 24 | 0.01 25 | 13. hectopoise [hP]: 26 | 0.1 27 | 14. dekapoise [daP]: 28 | 1 29 | 15. decipoise [dP]: 30 | 100 31 | 16. centipoise [cP]: 32 | 1000 33 | 17. millipoise [mP]: 34 | 10000 35 | 18. micropoise [uP]: 36 | 10000000 37 | 19. nanopoise [nP]: 38 | 1e+10 39 | 20. picopoise [pP]: 40 | 1e+13 41 | 21. femtopoise [fP]: 42 | 1e+16 43 | 22. attopoise [aP]: 44 | 1e+19 45 | 23. pound-force second/square inch: 46 | 0.000145038 47 | 24. pound-force second/square foot: 48 | 0.02088543 49 | 25. poundal second/square foot: 50 | 0.671969 51 | 26. gram/centimeter/second: 52 | 10 53 | 27. slug/foot/second [slug/(ft.s)]: 54 | 0.02088543 55 | 28. pound/foot/second [lb/(ft.s)]: 56 | 0.671969 57 | 29. pound/foot/hour [lb/(ft.h)]: 58 | 2419.08831 -------------------------------------------------------------------------------- /test/python/test_conversion.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019-2025, 2 | # Lawrence Livermore National Security, LLC; 3 | # See the top-level NOTICE for additional details. All rights reserved. 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | import units_llnl as u 7 | 8 | 9 | def test_convert_units(): 10 | u1 = u.Unit("m") 11 | u2 = u.Unit("cm") 12 | v1 = u.convert(10, u1, u2) 13 | assert v1 == 10 * 100 14 | 15 | v2 = u.convert(unit_in=u1, unit_out=u2, value=20) 16 | assert v2 == 2000 17 | 18 | 19 | def test_convert_string(): 20 | v1 = u.convert(10, "m", "mm") 21 | assert v1 == 10 * 1000 22 | 23 | v2 = u.convert(unit_out="mm", unit_in="m", value=20) 24 | assert v2 == 20000 25 | 26 | 27 | def test_convert_units_pu(): 28 | u1 = u.Unit("puMW") 29 | u2 = u.Unit("kW") 30 | v1 = u.convert_pu(0.5, u1, u2, 100) 31 | assert v1 == 50000 32 | 33 | v2 = u.convert_pu(unit_in=u1, unit_out=u2, value=1.2, base=100) 34 | assert v2 == 120000 35 | 36 | 37 | def test_convert_string_pu(): 38 | v1 = u.convert_pu(0.5, "puMW", "kW", 100) 39 | assert v1 == 50000 40 | 41 | v2 = u.convert_pu(unit_in="puMW", unit_out="kW", value=1.2, base=100) 42 | assert v2 == 120000 43 | -------------------------------------------------------------------------------- /NOTICE: -------------------------------------------------------------------------------- 1 | This work was produced under the auspices of the U.S. Department of 2 | Energy by Lawrence Livermore National Laboratory under Contract 3 | DE-AC52-07NA27344. 4 | 5 | This work was prepared as an account of work sponsored by an agency of 6 | the United States Government. Neither the United States Government nor 7 | Lawrence Livermore National Security, LLC, nor any of their employees 8 | makes any warranty, expressed or implied, or assumes any legal liability 9 | or responsibility for the accuracy, completeness, or usefulness of any 10 | information, apparatus, product, or process disclosed, or represents that 11 | its use would not infringe privately owned rights. 12 | 13 | Reference herein to any specific commercial product, process, or service 14 | by trade name, trademark, manufacturer, or otherwise does not necessarily 15 | constitute or imply its endorsement, recommendation, or favoring by the 16 | United States Government or Lawrence Livermore National Security, LLC. 17 | 18 | The views and opinions of authors expressed herein do not necessarily 19 | state or reflect those of the United States Government or Lawrence 20 | Livermore National Security, LLC, and shall not be used for advertising 21 | or product endorsement purposes. 22 | -------------------------------------------------------------------------------- /test/files/test_conversions/molar_flow_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. mole/second [mol/s]: 2 | 1 3 | 2. examole/second [Emol/s]: 4 | 1e-18 5 | 3. petamole/second [Pmol/s]: 6 | 1e-15 7 | 4. teramole/second [Tmol/s]: 8 | 1e-12 9 | 5. gigamole/second [Gmol/s]: 10 | 1e-9 11 | 6. megamole/second [Mmol/s]: 12 | 0.000001 13 | 7. kilomole/second [kmol/s]: 14 | 0.001 15 | 8. hectomole/second [hmol/s]: 16 | 0.01 17 | 9. dekamole/second [damol/s]: 18 | 0.1 19 | 10. decimole/second [dmol/s]: 20 | 10 21 | 11. centimole/second [cmol/s]: 22 | 100 23 | 12. millimole/second [mmol/s]: 24 | 1000 25 | 13. micromole/second [umol/s]: 26 | 1000000 27 | 14. nanomole/second [nmol/s]: 28 | 1e+9 29 | 15. picomole/second [pmol/s]: 30 | 1e+12 31 | 16. femtomole/second [fmol/s]: 32 | 1e+15 33 | 17. attomole/second [amol/s]: 34 | 1e+18 35 | 18. mole/minute [mol/min]: 36 | 60 37 | 19. mole/hour [mol/h]: 38 | 3600 39 | 20. mole/day [mol/d]: 40 | 86400 41 | 21. millimole/minute [mmol/min]: 42 | 60000 43 | 22. millimole/hour [mmol/h]: 44 | 3600000 45 | 23. millimole/day [mmol/d]: 46 | 86400000.000001 47 | 24. nanomole/day [nmol/d]: 48 | 8.64e+13 49 | 25. kilomole/minute [kmol/min]: 50 | 0.06 51 | 26. kilomole/hour [kmol/h]: 52 | 3.6 53 | 27. kilomole/day [kmol/d]: 54 | 86.4 55 | 28. atom/second [atom/s]: 56 | 6.02e+23 -------------------------------------------------------------------------------- /test/files/test_conversions/surface_current_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. ampere/square meter [A/m2]: 2 | 1 3 | 2. ampere/square kilometer: 4 | 1000000 5 | 3. ampere/square decimeter: 6 | 0.01 7 | 4. ampere/square centimeter: 8 | 0.0001 9 | 5. ampere/square millimeter: 10 | 0.000001 11 | 6. ampere/square micrometer: 12 | 1e-12 13 | 7. ampere/square nanometer: 14 | 1e-18 15 | 8. kiloampere/square meter: 16 | 0.001 17 | 9. kiloampere/square decimeter: 18 | 0.00001 19 | 10. kiloampere/square centimeter: 20 | 1e-7 21 | 11. kiloampere/square millimeter: 22 | 1e-9 23 | 12. kiloampere/square micrometer: 24 | 1e-15 25 | 13. kiloampere/square nanometer: 26 | 1e-21 27 | 14. milliampere/square meter: 28 | 1000 29 | 15. microampere/square meter: 30 | 1000000 31 | 16. megaampere/square meter: 32 | 0.000001 33 | 17. biot/square meter [Bi/m2]: 34 | 0.1 35 | 18. abampere/square meter: 36 | 0.1 37 | 19. statampere/square micrometer: 38 | 0.002997925 39 | 20. statampere/square nanometer: 40 | 3e-9 41 | 21. kiloampere/square yard: 42 | 0.0008361274 43 | 22. kiloampere/square foot: 44 | 0.00009290304 45 | 23. kiloampere/square inch: 46 | 6.4516e-7 47 | 24. ampere/square yard [A/yd2]: 48 | 0.836127 49 | 25. ampere/square foot [A/ft2]: 50 | 0.09290304 51 | 26. ampere/square inch [A/in2]: 52 | 0.00064516 -------------------------------------------------------------------------------- /docs/reference/generate_currency_codes.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | 3 | # Load the XLS file 4 | file_path = "list-one.xls" 5 | xls_data = pd.read_excel(file_path, sheet_name="Active") 6 | 7 | outfile = open("currencydata.txt", "w") 8 | for index, row in xls_data.iterrows(): 9 | if index >= 3: 10 | currency = row.iloc[1] 11 | if currency in ["US Dollar", "Euro"]: 12 | continue 13 | if len(currency) > 39: 14 | continue 15 | currency = currency.replace(" ", "") 16 | line1 = ( 17 | f'{{"{currency}",{{1.0, precise::currency, generateCurrencyCode("{row.iloc[2]}")}}}},' 18 | ) 19 | outfile.write(f"{line1}\n") 20 | 21 | outfile.write("\n\n\n") 22 | outfile.write( 23 | "UNITS_CPP14_CONSTEXPR_OBJECT std::array, 1213> defined_commodity_codes{\n" 24 | ) 25 | 26 | for index, row in xls_data.iterrows(): 27 | if index >= 3: 28 | currency = row.iloc[1] 29 | if currency in ["US Dollar", "Euro"]: 30 | continue 31 | outfile.write(f'{{"{row.iloc[2]}",generateCurrencyCode("{row.iloc[2]}")}},\n') 32 | outfile.write(f'{{"{row.iloc[3]}",generateCurrencyCode("{row.iloc[2]}")}},\n') 33 | 34 | outfile.write("};\n\n") 35 | -------------------------------------------------------------------------------- /docs/_static/convert.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Units Library String Conversions 5 | 6 | 7 | 8 |

Units Library String Conversions

9 |

10 | Source 11 | Documentation 14 |

15 |
16 |
    17 | Measurement string:
    18 |
    19 | E.g. "25 m", "ten tons", "3.252Tesla", "237uL" 20 |
    21 | 22 |
    convert to:
    23 |
    24 | E.g. "inches", "lb", "Gauss", "tsp" 25 |
    26 | "use '*' to convert to base units 27 |

    28 | 29 | 35 | 36 |
37 |
38 | 39 | 40 | -------------------------------------------------------------------------------- /test/files/test_conversions/concentration_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. mol/cubic meter [mol/m3]: 2 | 1 3 | 2. mol/liter [mol/L]: 4 | 0.001 5 | 3. mol/cubic decimeter [mol/dm3]: 6 | 0.001 7 | 4. mol/cubic centimeter: 8 | 0.000001 9 | 5. mol/cubic millimeter: 10 | 1e-9 11 | 6. kilomol/cubic meter [kmol/m3]: 12 | 0.001 13 | 7. kilomol/liter [kmol/L]: 14 | 0.000001 15 | 8. kilomol/cubic centimeter: 16 | 1e-9 17 | 9. kilomol/cubic millimeter: 18 | 1e-12 19 | 10. millimole/cubic meter: 20 | 1000 21 | 11. millimole/liter [mmol/L]: 22 | 1 23 | 12. millimole/cubic centimeter: 24 | 0.001 25 | 13. millimole/cubic millimeter: 26 | 0.000001 27 | 14. millimole/milliliter: 28 | 0.001 29 | 15. micromole/liter [umol/l]: 30 | 1000 31 | 16. micromol/milliliter [umol/mL]: 32 | 1 33 | 17. micromol/microliter [umol/uL]: 34 | 0.001 35 | 18. picomol/microliter [pmol/uL]: 36 | 1000 37 | 19. picomol/milliliter [pmol/mL]: 38 | 1000000 39 | 20. picomole/liter [pmol/l]: 40 | 1e+9 41 | 21. nanomole/liter [nmol/l]: 42 | 1000000 43 | 22. nanomole/milliliter [nmol/mL]: 44 | 1000 45 | 23. nanomole/microliter [nmol/uL]: 46 | 1 47 | 24. Molar [M]: 48 | 0.001 49 | 25. milliMolar [mM]: 50 | 1 51 | 26. microMolar [uM]: 52 | 1000 53 | 27. nanoMolar [nM]: 54 | 1000000 55 | 28. picoMolar [pM]: 56 | 1e+9 57 | 29. femtoMolar [fM]: 58 | 1e+12 -------------------------------------------------------------------------------- /test/files/test_conversions/molar_concentration_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. mol/cubic meter [mol/m3]: 2 | 1 3 | 2. mol/liter [mol/L]: 4 | 0.001 5 | 3. mol/cubic decimeter [mol/dm3]: 6 | 0.001 7 | 4. mol/cubic centimeter: 8 | 0.000001 9 | 5. mol/cubic millimeter: 10 | 1e-9 11 | 6. kilomol/cubic meter [kmol/m3]: 12 | 0.001 13 | 7. kilomol/liter [kmol/L]: 14 | 0.000001 15 | 8. kilomol/cubic centimeter: 16 | 1e-9 17 | 9. kilomol/cubic millimeter: 18 | 1e-12 19 | 10. millimole/cubic meter: 20 | 1000 21 | 11. millimole/liter [mmol/L]: 22 | 1 23 | 12. millimole/cubic centimeter: 24 | 0.001 25 | 13. millimole/cubic millimeter: 26 | 0.000001 27 | 14. millimole/milliliter: 28 | 0.001 29 | 15. micromole/liter [umol/l]: 30 | 1000 31 | 16. micromol/milliliter [umol/mL]: 32 | 1 33 | 17. micromol/microliter [umol/uL]: 34 | 0.001 35 | 18. picomol/microliter [pmol/uL]: 36 | 1000 37 | 19. picomol/milliliter [pmol/mL]: 38 | 1000000 39 | 20. picomole/liter [pmol/l]: 40 | 1e+9 41 | 21. nanomole/liter [nmol/l]: 42 | 1000000 43 | 22. nanomole/milliliter [nmol/mL]: 44 | 1000 45 | 23. nanomole/microliter [nmol/uL]: 46 | 1 47 | 24. Molar [M]: 48 | 0.001 49 | 25. milliMolar [mM]: 50 | 1 51 | 26. microMolar [uM]: 52 | 1000 53 | 27. nanoMolar [nM]: 54 | 1000000 55 | 28. picoMolar [pM]: 56 | 1e+9 57 | 29. femtoMolar [fM]: 58 | 1e+12 -------------------------------------------------------------------------------- /docs/user-guide/measurements.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | Measurements 3 | ============ 4 | 5 | The combination of a value and unit is known as a measurement. In the units library they are constructed by multiplying or dividing a unit by a numerical value. 6 | 7 | .. code-block:: c++ 8 | 9 | measurement meas=10.0*m; 10 | measurement meas2=5.3/s; 11 | 12 | 13 | They can also be constructed via the constructor 14 | 15 | .. code-block:: c++ 16 | 17 | measurement meas(10.0, kg); 18 | measurement meas2(2.7, MW); 19 | 20 | There are two kinds of measurements the regular `measurement` which uses a double precision floating point for the value and a `precise_measurement` which uses a double and a `precise_unit`. 21 | In terms of size the `measurement` class is 16 Bytes and the `precise_measurement` is 24 bytes. 22 | 23 | Precise measurements 24 | ---------------------- 25 | 26 | A precise measurement includes a double for the value and a precise_unit to represent the unit. Most of the string conversion routines to measurement produce a precise_measurement. 27 | the `measurement_cast` operation will convert a precise_measurement into a regular measurements. 28 | 29 | .. code-block:: c++ 30 | 31 | precise_measurement mp(10.0, precise::kg); 32 | measurement meas2=measurement_cast(mp); 33 | -------------------------------------------------------------------------------- /webserver/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Units Library String Conversions 5 | 6 | 7 | 8 |

Units Library String Conversions

9 |

10 | Source 11 | Documentation 14 |

15 |
16 |
    17 | Measurement string: 18 |
    19 | 20 |
    21 | E.g. "25 m", "ten tons", "3.252Tesla", "237uL" 22 |
    23 | 24 |
    convert to: 25 |
    26 | 27 |
    28 | E.g. "inches", "lb", "Gauss", "tsp" 29 |
    30 | "use '*' to convert to base units 31 |
    32 | 33 | 39 | 40 |
41 |
42 | 43 | 44 | -------------------------------------------------------------------------------- /FuzzTargets/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM helics/buildenv:clang14-builder as builder 2 | 3 | # this is already in a workdir from the builder image 4 | 5 | WORKDIR /root/develop 6 | 7 | RUN git clone https://github.com/LLNL/units.git units 8 | 9 | WORKDIR /root/develop/build 10 | 11 | RUN cmake ../units -DUNITS_BUILD_FUZZ_TARGETS=ON -DCMAKE_CXX_STANDARD=17 -DUNITS_INSTALL=OFF -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_COMPILER_FORCED=ON -DCMAKE_CXX_FLAGS="-g -O1 -fsanitize=fuzzer" && make -j2 12 | 13 | WORKDIR /root/develop/fuzz_targets 14 | 15 | RUN cp ../build/bin/fuzz_measurement . && cp ../units/FuzzTargets/*.txt . && cp ../units/FuzzTargets/*.sh . 16 | 17 | FROM ubuntu:22.04 18 | 19 | COPY --from=builder /root/develop/fuzz_targets /root/develop/fuzz_targets 20 | 21 | RUN export VCS_REF=$(cat /root/develop/Fuzz_targets/commit_hash) 22 | 23 | ARG GIT_COMMIT=unspecified 24 | 25 | LABEL maintainer="top1@llnl.gov" 26 | 27 | LABEL name="units.fuzzer" 28 | LABEL description="Units library fuzzer" 29 | LABEL vcs-ref=$GIT_COMMIT 30 | LABEL vcs-url="https://github.com/LLNL/units" 31 | LABEL version="0.9.1" 32 | LABEL date="2023-09-01" 33 | 34 | VOLUME /fuzz 35 | 36 | #ENV ASAN_OPTIONS='quarantine_size_mb=16:max_redzone=512:detect_leaks=0:max_malloc_fill_size=1024' 37 | 38 | WORKDIR /root/develop/fuzz_targets 39 | 40 | CMD ["./fuzz_script.sh"] 41 | -------------------------------------------------------------------------------- /test/files/test_conversions/area_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. square meter [m2]: 2 | 1 3 | 2. square kilometer [km2]: 4 | 0.000001 5 | 3. square hectometer [hm2]: 6 | 0.0001 7 | 4. square dekameter [dam2]: 8 | 0.01 9 | 5. square decimeter [dm2]: 10 | 100 11 | 6. square centimeter [cm2]: 12 | 10000 13 | 7. square millimeter [mm2]: 14 | 1000000 15 | 8. square micrometer [um2]: 16 | 1e+12 17 | 9. square nanometer [nm2]: 18 | 1e+18 19 | 10. hectare [ha]: 20 | 0.0001 21 | 11. are: 22 | 0.01 23 | 12. barn [b]: 24 | 1e+28 25 | 14. circular inch: 26 | 1973.525241 27 | 15. circular mil: 28 | 1.973525e+9 29 | 17. square inch [in2]: 30 | 1550.0031 31 | 18. square foot [ft2]: 32 | 10.76391 33 | 19. square yard [yd2]: 34 | 1.19599 35 | 20. square mile [mi2]: 36 | 3.861022e-7 37 | 21. acre [ac]: 38 | 0.0002471054 39 | 22. township: 40 | 1.072667e-8 41 | 23. homestead: 42 | 0.000001543828 43 | 24. rood: 44 | 0.0009885224 45 | 25. square perch: 46 | 0.0395409 47 | 26. square rod: 48 | 0.0395409 49 | 27. section: 50 | 3.861022e-7 51 | 28. square pole: 52 | 0.0395409 53 | 29. square chain [ch2]: 54 | 0.0024710538 55 | 30. square mil [mil2]: 56 | 1.550003e+9 57 | 33. square foot (US survey): 58 | 10.763867 59 | 34. square mile (US survey): 60 | 3.861006e-7 61 | 35. acre (US survey): 62 | 0.0002471044 63 | 36. square rod (US survey): 64 | 0.0395367 65 | 37. square yard (US survey): 66 | 1.195985 67 | 38. square inch (US survey): 68 | 1549.9969 -------------------------------------------------------------------------------- /test/python/test_user_defined.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2019-2025, 2 | # Lawrence Livermore National Security, LLC; 3 | # See the top-level NOTICE for additional details. All rights reserved. 4 | # SPDX-License-Identifier: BSD-3-Clause 5 | 6 | from units_llnl import Unit, add_user_defined_unit, defined_units_from_file 7 | 8 | 9 | def test_user_defined_unit(): 10 | clucks = Unit("19.3 m*A") 11 | 12 | add_user_defined_unit("clucks", clucks) 13 | add_user_defined_unit("sclucks", "23 m*mol*$") 14 | 15 | assert Unit("clucks/A") == Unit("19.3 m") 16 | assert Unit("sclucks/$") == Unit("23 m*mol") 17 | 18 | assert str(clucks) == "clucks" 19 | assert str(~clucks) == "1/clucks" 20 | 21 | sclucks = Unit("sclucks") 22 | assert not sclucks.is_error() 23 | assert str(Unit("ug") / sclucks**3) == "ug/sclucks^3" 24 | 25 | 26 | def test_user_defined_unit_from_file(): 27 | import os.path 28 | 29 | script_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 30 | outputstr = defined_units_from_file( 31 | os.path.join(script_dir, "files/test_unit_files/other_units2.txt") 32 | ) 33 | assert not outputstr 34 | y1 = Unit("yodles") 35 | assert y1 == Unit("73.0 count") 36 | 37 | y2 = Unit("yeedles") 38 | assert y2 == Unit("19.0 yodles") 39 | y3 = Unit("yimdles") 40 | assert y3 == Unit("12 yeedles") 41 | assert y3 == Unit("19*yodles*12") 42 | -------------------------------------------------------------------------------- /test/files/test_conversions/force_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. newton [N]: 2 | 1 3 | 2. kg.m/s^2 [kg.m/s2]: 4 | 1 5 | 3. kilonewton [kN]: 6 | 0.001 7 | 4. meganewton [MN]: 8 | 0.000001 9 | 5. hectonewton [hN]: 10 | 0.01 11 | 6. dekanewton [daN]: 12 | 0.1 13 | 7. decinewton [dN]: 14 | 10 15 | 8. centinewton [cN]: 16 | 100 17 | 9. millinewton [mN]: 18 | 1000 19 | 10. micronewton [uN]: 20 | 1000000 21 | 11. nanonewton [nN]: 22 | 1e+9 23 | 12. piconewton [pN]: 24 | 1e+12 25 | 13. femtonewton [fN]: 26 | 1e+15 27 | 14. attonewton [aN]: 28 | 1e+18 29 | 15. giganewton [GN]: 30 | 1e-9 31 | 16. teranewton [TN]: 32 | 1e-12 33 | 17. petanewton [PN]: 34 | 1e-15 35 | 18. exanewton [EN]: 36 | 1e-18 37 | 19. dyne [dyn]: 38 | 100000 39 | 20. joule/meter [J/m]: 40 | 1 41 | 21. joule/centimeter [J/cm]: 42 | 0.01 43 | 22. gram-force [gf]: 44 | 101.971621 45 | 23. kilogram-force [kgf]: 46 | 0.101972 47 | 24. ton-force (metric) [tf]: 48 | 0.0001019716 49 | 25. milligram force [mgf]: 50 | 101971.6213 51 | 26. microgram force [ugf]: 52 | 1.019716e+8 53 | 27. pond : 54 | 101.971621 55 | 28. kilopond [kp]: 56 | 0.101972 57 | 29. ton-force (short) [tonf (US)]: 58 | 0.000112404 59 | 30. ton-force (long) [tonf (UK)]: 60 | 0.000100361 61 | 31. ounce-force [ozf]: 62 | 3.596943 63 | 32. kilopound-force [kipf]: 64 | 0.0002248089 65 | 33. pound-force [lbf]: 66 | 0.224809 67 | 34. poundal [pdl]: 68 | 7.233014 69 | 35. pound foot/square second: 70 | 7.233014 71 | 36. pound yard/square second: 72 | 2.411005 -------------------------------------------------------------------------------- /test/files/test_conversions/force_moment_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. centinewton meter [cN.m]: 2 | 1000 3 | 2. dyne meter [dyn.m]: 4 | 1000000 5 | 3. kilonewton centimeter: 6 | 1 7 | 4. kilonewton decimeter: 8 | 0.1 9 | 5. kilonewton meter [kN.m]: 10 | 0.01 11 | 6. kilonewton micrometer[kN.um]: 12 | 10000 13 | 7. kilonewton micron: 14 | 10000 15 | 8. kilonewton millimeter: 16 | 10 17 | 9. newton meter [N.m]: 18 | 10 19 | 10. newton millimeter [N.mm]: 20 | 10000 21 | 11. millinewton meter [mN.m]: 22 | 10000 23 | 12. gram-force meter [gf.m]: 24 | 1019.716213 25 | 13. tonne-force meter [tf.m]: 26 | 0.0010197162 27 | 14. kilogram-force meter: 28 | 1.019716 29 | 15. kilonewton foot [kN.ft]: 30 | 0.0328084 31 | 16. kilonewton inch [kN.in]: 32 | 0.39370079 33 | 17. kilonewton yard [kN.yd]: 34 | 0.01093613298 35 | 18. newton yard [N.yd]: 36 | 010.93613298 37 | 19. newton foot [N.ft]: 38 | 32.8084 39 | 20. newton inch [N.in]: 40 | 393.70079 41 | 21. kilopound-force meter: 42 | 0.00224809 43 | 22. ounce-force meter [ozf.m]: 44 | 35.969431 45 | 23. pound-force meter [lbf.m]: 46 | 2.248089 47 | 24. ounce-force yard [ozf.yd]: 48 | 39.336648 49 | 25. ounce-force foot [ozf.ft]: 50 | 118.009944 51 | 26. ounce-force inch [ozf.in]: 52 | 1416.119328 53 | 27. pound-force yard [lbf.yd]: 54 | 2.458541 55 | 28. pound-force foot [lbf.ft]: 56 | 7.375622 57 | 29. pound-force inch [lbf.in]: 58 | 88.507458 59 | 30. newton mile [N.mi]: 60 | 0.00621371 61 | 31. poundal meter [pdl.m]: 62 | 72.330139 -------------------------------------------------------------------------------- /test/files/test_conversions/heat_flux_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. watt/square meter [W/m2]: 2 | 1 3 | 2. watt/square centimeter: 4 | 0.0001 5 | 3. milliwatt/square centimeter: 6 | 0.1 7 | 4. kilowatt/square meter: 8 | 0.001 9 | 5. joule/second/square meter: 10 | 1 11 | 6. kilocalorie (IT)/hour/square meter: 12 | 0.85986 13 | 7. calorie (IT)/second/square centimeter: 14 | 0.000023885 15 | 8. calorie (IT)/minute/square centimeter: 16 | 0.0014331 17 | 9. calorie (IT)/hour/square centimeter: 18 | 0.085986 19 | 10. calorie (th)/second/square centimeter: 20 | 0.000023900574 21 | 11. calorie (th)/minute/square centimeter: 22 | 0.0014340344 23 | 12. calorie (th)/hour/square centimeter: 24 | 0.08604206 25 | 13. dyne/hour/centimeter: 26 | 3600000 27 | 14. erg/hour/square millimeter: 28 | 36000 29 | 15. foot pound force/minute/square foot: 30 | 4.111306 31 | 16. horsepower/square foot: 32 | 0.000124585 33 | 17. horsepower (metric)/square foot: 34 | 0.000126313 35 | 18. Btu (IT)/second/square foot: 36 | 0.000088055 37 | 19. Btu (IT)/minute/square foot: 38 | 0.0052833 39 | 20. Btu (IT)/hour/square foot: 40 | 0.316998 41 | 21. Btu (th)/second/square inch: 42 | 6.119029e-7 43 | 22. Btu (th)/second/square foot: 44 | 0.000088114017 45 | 23. Btu (th)/minute/square foot: 46 | 0.005286841 47 | 24. Btu (th)/hour/square inch: 48 | 0.0022028504 49 | 25. CHU/hour/square foot: 50 | 0.17611 51 | 26. watt/square inch [W/in2]: 52 | 0.00064516 53 | 27. kilocalorie (th)/hour/square foot: 54 | 0.07988224 -------------------------------------------------------------------------------- /test/files/test_conversions/data_transfer_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. bit/second [bps]: 2 | 1000 3 | 2. bit/microsecond [bit/us]: 4 | 0.001 5 | 3. bit/millisecond [bit/ms]: 6 | 1 7 | 4. bit/nanosecond [bit/ns]: 8 | 0.000001 9 | 5. byte/microsecond [By/us]: 10 | 0.000125 11 | 6. byte/millisecond [By/ms]: 12 | 0.125 13 | 7. byte/nanosecond [By/ns]: 14 | 1.25e-7 15 | 8. byte/second [By/s]: 16 | 125 17 | 12. terabit/second [Tbps]: 18 | 1e-9 19 | 13. gigabit/second [Gbps]: 20 | 1e-6 21 | 14. kilobit/microsecond [kb/us]: 22 | 1e-6 23 | 14. kibibit/microsecond [Kib/us]: 24 | 9.765625e-7 25 | 15. kilobit/millisecond [kb/ms]: 26 | 0.001 27 | 16. kilobit/second [Kbps]: 28 | 1 29 | 17. kilobyte/millisecond: 30 | 0.000125 31 | 18. kilobyte/second [kB/s]: 32 | 0.125 33 | 19. megabit/millisecond [Mb/ms]: 34 | 1e-6 35 | 20. mebibit/second [Mibps]: 36 | 0.0009536743 37 | 20. megabit/second [Mbps]: 38 | 0.001 39 | 21. megabyte/second [MB/s]: 40 | 0.000125 41 | 22. gibibit/day [Gib/d]: 42 | 0.08046627 43 | 23. tebibit/day [Tib/d]: 44 | 0.000078580 45 | 24. gibibyte/day [GiB/d]: 46 | 0.010058284 47 | 25. kibibit/minute [Kib/min]: 48 | 58.59375 49 | 26. kibibyte/minute [KiB/min]: 50 | 7.324219 51 | 27. mebibit/minute [Mib/min]: 52 | 0.05722046 53 | 28. mebibyte/minute [MiB/min]: 54 | 0.0071525574 55 | 29. gibibit/minute [Gib/min]: 56 | 0.000055879354 57 | 30. gibibyte/minute [GiB/min]: 58 | 0.000006984919 59 | 31. kibibit/hour [Kib/h]: 60 | 3515.625 61 | 32. kibibyte/hour [KiB/h]: 62 | 439.453125 -------------------------------------------------------------------------------- /test/files/test_conversions/mass_flow_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. kilogram/second [kg/s]: 2 | 1 3 | 2. kilogram/minute [kg/min]: 4 | 60 5 | 3. kilogram/hour [kg/h]: 6 | 3600 7 | 4. kilogram/day [kg/d]: 8 | 86400 9 | 5. milligram/day [mg/d]: 10 | 8.64e+10 11 | 6. gram/day [g/d]: 12 | 86400000.000001 13 | 7. gram/second [g/s]: 14 | 1000 15 | 8. gram/minute [g/min]: 16 | 60000 17 | 9. gram/hour [g/h]: 18 | 3600000 19 | 10. milligram/second [mg/s]: 20 | 1000000 21 | 11. milligram/minute [mg/min]: 22 | 59999999.999999 23 | 12. milligram/hour [mg/h]: 24 | 3.6e+9 25 | 13. exagram/second [Eg/s]: 26 | 1e-15 27 | 14. petagram/second [Pg/s]: 28 | 1e-12 29 | 15. teragram/second [Tg/s]: 30 | 1e-9 31 | 16. gigagram/second [Gg/s]: 32 | 0.000001 33 | 17. megagram/second [Mg/s]: 34 | 0.001 35 | 18. hectogram/second [hg/s]: 36 | 10 37 | 19. dekagram/second [dag/s]: 38 | 100 39 | 20. decigram/second [dg/s]: 40 | 10000 41 | 21. centigram/second [cg/s]: 42 | 100000 43 | 22. microgram/second [ug/s]: 44 | 1e+9 45 | 23. ton (metric)/second [t/s]: 46 | 0.001 47 | 24. ton (metric)/minute [t/min]: 48 | 0.06 49 | 25. ton (metric)/hour [t/h]: 50 | 3.6 51 | 26. ton (metric)/day [t/d]: 52 | 86.4 53 | 27. ton (short)/hour [ton (US)/h]: 54 | 3.968321 55 | 28. pound/day [lb/d]: 56 | 190479.3945 57 | 29. pound/second [lb/s]: 58 | 2.204623 59 | 30. pound/minute [lb/min]: 60 | 132.277357 61 | 31. pound/hour [lb/h]: 62 | 7936.641438 63 | 32. ounce/second [oz/s]: 64 | 35.273962 65 | 33. ounce/minute [oz/min]: 66 | 2116.437717 -------------------------------------------------------------------------------- /webserver/convert.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Units Library String Conversions 5 | 6 | 7 | 8 |

Units Library String Conversions

9 |

10 | Source 11 | Documentation 14 |

15 | 16 |
17 |
    18 | Measurement string: 19 |
    20 | 21 |
    22 | E.g. "25 m", "ten tons", "3.252Tesla", "237uL" 23 |
    24 |
    convert to (units): 25 |
    26 | 27 |
    28 | E.g. "inches", "lb", "Gauss", "tsp" 29 |
    30 | "use '*' to convert to base units 31 |
    32 |
    33 | 34 | 40 | 41 |
42 |
43 | $M2$ = $VALUE$ $U2$ 44 | 45 | 46 | -------------------------------------------------------------------------------- /FuzzTargets/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | # Copyright (c) 2019-2025, 3 | # Lawrence Livermore National Security, LLC; 4 | # See the top-level NOTICE for additional details. All rights reserved. 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 | 8 | add_executable(fuzz_from_string fuzz_target_from_string.cpp) 9 | target_link_libraries( 10 | fuzz_from_string ${UNITS_LC_PROJECT_NAME}::units compile_flags_target 11 | ) 12 | target_include_directories(fuzz_from_string PRIVATE ${CMAKE_SOURCE_DIR}/ThirdParty) 13 | 14 | add_executable(fuzz_measurement fuzz_target_measurement_from_string.cpp) 15 | target_link_libraries( 16 | fuzz_measurement ${UNITS_LC_PROJECT_NAME}::units compile_flags_target 17 | ) 18 | target_include_directories(fuzz_measurement PRIVATE ${CMAKE_SOURCE_DIR}/ThirdParty) 19 | 20 | add_custom_target( 21 | QUICK_RAW_FUZZ 22 | COMMAND ${CMAKE_COMMAND} -E make_directory corp2 23 | COMMAND 24 | fuzz_measurement corp2 -max_total_time=300 -max_len=512 25 | -dict=${CMAKE_CURRENT_SOURCE_DIR}/fuzz_dictionary.txt 26 | -exact_artifact_path=units_fail_measurement_artifact.txt 27 | COMMAND ${CMAKE_COMMAND} -E make_directory corp1 28 | COMMAND 29 | fuzz_from_string corp1 -max_total_time=300 -max_len=512 30 | -dict=${CMAKE_CURRENT_SOURCE_DIR}/fuzz_dictionary.txt 31 | -exact_artifact_path=units_fail_string_artifact.txt 32 | ) 33 | -------------------------------------------------------------------------------- /test/files/test_conversions/velocity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. meter/second [mps]: 2 | 1 3 | 2. meter/millisecond [m/ms]: 4 | 0.001 5 | 3. meter/microsecond [m/us]: 6 | 0.000001 7 | 4. meter/nanosecond [m/ns]: 8 | 1e-9 9 | 5. meter/minute [m/min]: 10 | 59.999999 11 | 6. centimeter/minute [cm/min]: 12 | 6000 13 | 7. kilometer/second [km/s]: 14 | 0.001 15 | 8. kilometer/millisecond: 16 | 0.000001 17 | 9. kilometer/microsecond: 18 | 1e-9 19 | 10. kilometer/nanosecond: 20 | 1e-12 21 | 11. kilometer/minute [km/min]: 22 | 0.06 23 | 12. kilometer/hour [kph]: 24 | 3.6 25 | 13. kilometer/day [km/d]: 26 | 86.4 27 | 14. hectometer/second [hm/s]: 28 | 0.01 29 | 15. decimeter/second [dm/s]: 30 | 10 31 | 16. centimeter/second [cm/s]: 32 | 100 33 | 17. millimeter/second [mm/s]: 34 | 1000 35 | 18. micrometer/second [um/s]: 36 | 1000000 37 | 19. nanometer/second [nm/s]: 38 | 1e+9 39 | 20. picometer/second [pm/s]: 40 | 1e+12 41 | 21. mile/second [mi/s]: 42 | 0.000621371 43 | 22. mile/minute [mi/min]: 44 | 0.03728226 45 | 23. mile/hour [mph]: 46 | 2.236934 47 | 24. mile/day [mi/d]: 48 | 53.686798 49 | 25. nautical mile (international)/hour: 50 | 1.943844 51 | 26. nautical league (international)/hour: 52 | 0.647948 53 | 27. kiloyard/second [kyd/s]: 54 | 0.001093613 55 | 28. yard/second [yd/s]: 56 | 1.093613 57 | 29. yard/minute [yd/min]: 58 | 65.616798 59 | 30. yard/hour [yd/h]: 60 | 3937.007874 61 | 31. foot/second [fps]: 62 | 3.28084 63 | 32. foot/minute [fpm]: 64 | 196.850394 65 | 33. foot/hour [fph]: 66 | 11811.023622 67 | 34. inch/second [in/s]: 68 | 39.370079 69 | 35. knot [kn]: 70 | 1.943844 -------------------------------------------------------------------------------- /test/files/SI_Units.csv: -------------------------------------------------------------------------------- 1 | time,second,s, 2 | time,minute,min,60.s 3 | time,hour,h, 60.min 4 | time,day,d,24.h 5 | frequency,hertz,Hz,s^-1 6 | signaling rate,baud,Bd,bit*s^-1 7 | length,meter,m, 8 | volume,liter,L,dm^3 9 | plane angle,radian,rad, 10 | solid angle,steradian,sr,rad^2 11 | plane angle,revolution,r,6.283185307179586.rad 12 | plane angle,degree,o,2.777777777777778e-3.r 13 | information capacity,bit,bit, 14 | information capacity,byte,B,8.bit 15 | information capacity,octet,B,8.bit 16 | mass,gram,g, 17 | mass,tonne,t,Mg 18 | mass,unified atomic mass unit,u,1.660538782e-27.kg 19 | amount of substance,mole,mol, 20 | catalytic activity,katal,kat,mol/s 21 | thermodynamic temperature,kelvin,K, 22 | temperature,degree Celsius,oC, 23 | luminous intensity,candela,cd, 24 | luminous flux,lumen,lm,cd.sr 25 | illuminance,lux,lx,lm/m^2 26 | force,newton,N,m.kg.s^-2 27 | pressure,pascal,Pa,N/m^2 28 | stress,pascal,Pa,N/m^2 29 | energy,joule,J,N.m 30 | work,joule,J,N.m 31 | heat,joule,J,N.m 32 | energy,electronvolt,eV,1.602176487e-19.J 33 | power,watt,W,J/s 34 | radiant flux,watt,W,J/s 35 | logarithm of power ratio,neper,Np, 36 | logarithm of power ratio,decibel,dB,0.1151293.Np 37 | electric current,ampere,A, 38 | electric charge,coulomb,C,s.A 39 | electric potential,volt,V,W/A 40 | EMF,volt,V,W/A 41 | capacitance,farad,F,C/V 42 | electric resistance,ohm,Ohm,V/A 43 | electric conductance,siemens,S,A/V 44 | magnetic flux,weber,Wb,V.s 45 | magnetic flux density,tesla,T,Wb/m^2 46 | inductance,henry,H,Wb/A 47 | radionuclide activity,becquerel,Bq,count*s^-1 48 | absorbed dose energy,gray,Gy,m^2.s^-2 49 | dose equivalent,sievert,Sv,m^2.s^-2 50 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2019-2025, Lawrence Livermore National Security, LLC; 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | 3. Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /docs/user-guide/python.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Python 3 | ================== 4 | The Python wrapper for the units library is a simplified version of the library. It is focused on the string operations of the library and conversions between units and measurements. 5 | The two key classes are `Unit` which encapsulates a specific unit of measure and optional commodity if desired, and `Measurement` which captures a value + `Unit`. Math operations are supported on the types. 6 | The units library is available through a pypi_ package 7 | 8 | .. code-block:: sh 9 | 10 | pip install units-llnl 11 | 12 | Usage 13 | ----------- 14 | 15 | .. code-block:: python 16 | 17 | from units_llnl import Unit 18 | 19 | u1 = Unit("m") 20 | u2 = Unit("s") 21 | u3 = u1 / u2 22 | speed = 20 23 | desired = "mph" 24 | # convert the unit to miles per hour 25 | result = u3.convert(speed, desired) 26 | print(f"{20} {u3} = {result} {desired}") 27 | 28 | This will print a result `20 m/s = 44.73872584108805 mph` 29 | 30 | .. code-block:: python 31 | 32 | from units_llnl import Measurement 33 | 34 | m1 = Measurement("220 m") 35 | m2 = Measurement("11 s") 36 | m3 = m1 / m2 37 | desired = "mph" 38 | # convert the unit to miles per hour 39 | result = m3.convert_to(desired) 40 | print(f"{m3} = {result}") 41 | 42 | This will produce `20 m/s = 44.7387258411 mph` 43 | 44 | See the pypi_ landing page for a complete description of all methods and functions. 45 | 46 | .. _pypi: https://pypi.org/project/units-llnl/ 47 | 48 | Future expansions will include uncertain units and some additional math operations on measurements 49 | -------------------------------------------------------------------------------- /converter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | # Copyright (c) 2019-2025, 3 | # Lawrence Livermore National Security, LLC; 4 | # See the top-level NOTICE for additional details. All rights reserved. 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 | 8 | cmake_dependent_option( 9 | UNITS_BUILD_CONVERTER_APP "Build a unit converter app" ON 10 | "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME" OFF 11 | ) 12 | 13 | if(UNITS_BUILD_CONVERTER_APP) 14 | add_executable(units_convert converter.cpp) 15 | target_link_libraries( 16 | units_convert PUBLIC ${UNITS_LC_PROJECT_NAME}::units compile_flags_target 17 | ) 18 | target_include_directories(units_convert PRIVATE ${PROJECT_SOURCE_DIR}/ThirdParty) 19 | target_compile_definitions( 20 | units_convert PUBLIC UNITS_VERSION_STRING="${UNITS_VERSION}" 21 | CLI11_HAS_CODECVT=0 22 | ) 23 | if(CMAKE_CXX_STANDARD GREATER 16) 24 | if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION 25 | VERSION_EQUAL 8 26 | ) 27 | target_link_libraries(units_convert PRIVATE -lstdc++fs) 28 | endif() 29 | endif() 30 | 31 | if(UNITS_INSTALL) 32 | install( 33 | TARGETS units_convert ${UNITS_LIBRARY_EXPORT_COMMAND} 34 | DESTINATION "${CMAKE_INSTALL_BINDIR}" 35 | COMPONENT units_convert 36 | ) 37 | endif() 38 | add_executable(${UNITS_LC_PROJECT_NAME}::units_convert ALIAS units_convert) 39 | endif() 40 | -------------------------------------------------------------------------------- /test/files/test_conversions/volume_concentration_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. kilogram/liter [kg/L]: 2 | 1 3 | 2. gram/liter [g/L]: 4 | 1000 5 | 3. kilogram/m^3 [kg/m3]: 6 | 1000 7 | 4. gram/cubic meter [g/m3]: 8 | 1000000 9 | 5. microgram/cubic meter: 10 | 1e+12 11 | 6. gram/cubic centimeter: 12 | 1 13 | 7. milligram/liter [mg/L]: 14 | 1000000 15 | 8. milligram/mL [mg/mL]: 16 | 1000 17 | 9. milligram/teaspoon(metric) [mg/tsp_m]: 18 | 5000 19 | 10. microgram/uL [ug/uL]: 20 | 1000 21 | 11. picogram/microliter [pg/uL]: 22 | 1e+9 23 | 12. nanogram/microliter [ng/uL]: 24 | 1e6 25 | 13. picogram/milliliter [pg/mL]: 26 | 1e+12 27 | 14. picogram/liter [pg/L]: 28 | 1e+15 29 | 15. picogram/deciliter [pg/dL]: 30 | 1e+14 31 | 16. microgram/mL [ug/mL]: 32 | 1000000 33 | 17. microgram/deciliter [ug/dL]: 34 | 100000000 35 | 18. microgram/liter [ug/L]: 36 | 1e+9 37 | 19. nanogram/liter [ng/L]: 38 | 1e+12 39 | 20. nanogram/deciliter [ng/dL]: 40 | 1e+11 41 | 21. nanogram/milliliter [ng/ml]: 42 | 1e+9 43 | 22. gram/deciliter [g/dL]: 44 | 100 45 | 23. milligram/deciliter [mg/dL]: 46 | 100000 47 | 24. tonne/cubic meter [t/m3]: 48 | 1 49 | 25. pound/cubic yard [lb/yd3]: 50 | 1685.554936 51 | 26. pound/gallon (UK) [lb/gal (UK)]: 52 | 10.02241 53 | 27. pound/cubic foot [lb/ft3]: 54 | 62.427961 55 | 28. pound/gallon (US) [lb/gal (US)]: 56 | 8.345404 57 | 29. ounce/cubic inch [oz/in3]: 58 | 0.578037 59 | 30. ounce/cubic foot [oz/ft3]: 60 | 998.847369 61 | 31. ounce/cubic yard [oz/yd3]: 62 | 26968.878976 63 | 32. tonne/cubic yard [t/yd3]: 64 | 0.7646 65 | 33. pound/cubic inch [lbs/in3]: 66 | 0.03612729 67 | 38. slug/cubic foot [slug/ft3]: 68 | 1.94032 69 | 39. slug/cubic inch [slug/in3]: 70 | 0.00112287 71 | 40. slug/cubic yard [slug/yd3]: 72 | 52.388649 -------------------------------------------------------------------------------- /test/files/test_conversions/mass_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. gram [g]: 2 | 1000 3 | 2. kilogram [kg]: 4 | 1 5 | 3. pound [lb]: 6 | 2.204623 7 | 4. ounce [oz]: 8 | 35.273968 9 | 5. centigram [cg]: 10 | 100000 11 | 6. milligram [mg]: 12 | 1000000 13 | 7. microgram [ug]: 14 | 1e+9 15 | 8. nanogram [ng]: 16 | 1e+12 17 | 9. picogram [pg]: 18 | 1e+15 19 | 10. exagram [Eg]: 20 | 1e-15 21 | 11. petagram [Pg]: 22 | 1e-12 23 | 12. teragram [Tg]: 24 | 1e-9 25 | 13. gigagram [Gg]: 26 | 0.000001 27 | 14. megagram [Mg]: 28 | 0.001 29 | 15. hectogram [hg]: 30 | 10 31 | 16. dekagram [dag]: 32 | 100 33 | 17. decigram [dg]: 34 | 10000 35 | 18. femtogram [fg]: 36 | 1e+18 37 | 19. attogram [ag]: 38 | 1e+21 39 | 20. kilodalton [kDa]: 40 | 6.02e+23 41 | 21. dalton [Da]: 42 | 6.02e+26 43 | 22. kilogram-force square second/meter: 44 | 0.101972 45 | 23. ton (metric) [t]: 46 | 0.001 47 | 24. kiloton (metric) [kt]: 48 | 0.000001 49 | 25. quintal (metric): 50 | 0.01 51 | 26. carat [ct]: 52 | 5000 53 | 27. gamma: 54 | 1e+9 55 | 28. pound-force square second/foot: 56 | 0.06852178 57 | 29. slug: 58 | 0.06852178 59 | 30. kilopound [kip]: 60 | 0.002204623 61 | 31. ton (assay US): 62 | 34.285716 63 | 32. hundredweight (US): 64 | 0.02204623 65 | 34. stone (US): 66 | 0.17637 67 | 37. stone (UK): 68 | 0.157473 69 | 38. hundredweight (UK): 70 | 0.01968413 71 | 39. grain: 72 | 15432.361 73 | 40. pound (troy): 74 | 2.679229 75 | 41. ounce (troy): 76 | 32.150748 77 | 43. scruple (apothecary): 78 | 771.617952 79 | 44. ton (short): 80 | 0.001102 81 | 45. ton (long): 82 | 0.000984 83 | 46. tonne [t]: 84 | 0.001 85 | 47. ton (assay UK): 86 | 30.612245 87 | 48. Planck mass: 88 | 45940892.449999 89 | 49. jin (Chinese): 90 | 2 91 | 50. liang (Chinese): 92 | 10000 93 | 51. qian (Chinese): 94 | 100000 -------------------------------------------------------------------------------- /test/examples_test.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019-2025, 3 | Lawrence Livermore National Security, LLC; 4 | See the top-level NOTICE for additional details. All rights reserved. 5 | SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include "units/units_decl.hpp" 9 | 10 | #include "units/units.hpp" 11 | 12 | /** @file Test just to load up some unit definitions and do some operations with 13 | them it tests linking and some usefulness in code coverage */ 14 | 15 | int main(int /*argc*/, char* /*argv*/[]) 16 | { 17 | units::fixed_precise_measurement fpm1(1250.0, units::precise::cm.pow(3)); 18 | units::fixed_precise_measurement fpm2(1.25, units::precise::L); 19 | if (fpm1 != fpm2) { 20 | return -1; 21 | } 22 | 23 | units::uncertain_measurement um1(1250.0, 25.0, units::cm.pow(3)); 24 | units::uncertain_measurement um2(1.25, 0.1, units::L); 25 | if (um1 != um2) { 26 | return -1; 27 | } 28 | 29 | units::measurement m1(1250.0, units::cm.pow(3)); 30 | if (m1 != 1.25 * units::L) { 31 | return -1; 32 | } 33 | 34 | units::fixed_measurement fm1(1250.0, units::cm.pow(3)); 35 | if (fm1 != 1.25 * units::L) { 36 | return -1; 37 | } 38 | 39 | units::precise_measurement pm1 = 40 | units::measurement_from_string("1250 cm^3"); 41 | if (pm1 != 1.25 * units::precise::L) { 42 | return -1; 43 | } 44 | 45 | units::precise_unit prec1(1.25, units::precise::L); 46 | 47 | if (prec1 != units::precise_unit(0.00125, units::precise::m.pow(3))) { 48 | return -1; 49 | } 50 | 51 | units::unit u1(1.25, units::L); 52 | 53 | if (u1 != units::unit(0.00125, units::m.pow(3))) { 54 | return -1; 55 | } 56 | return 0; 57 | } 58 | -------------------------------------------------------------------------------- /config/.markdownlintrc: -------------------------------------------------------------------------------- 1 | rule "MD001" # header levels increment by 1 2 | rule "MD003", :style => :atx # header style - atx 3 | rule "MD004", :style => :dash # unordered list style - dash 4 | rule "MD005" # don't allow inconsistent indentation for list items 5 | rule "MD006" # start bullets at beginning of line 6 | rule "MD007", :indent => 2 # unordered list indentation should be 4 spaces 7 | rule "MD009" # trailing spaces not allowed 8 | rule "MD010" # hard tabs not allowed 9 | rule "MD011" # alert on reversed link syntax 10 | rule "MD012" # alert on multiple consecutive blank lines 11 | #rule "MD013" # line length should be no more than 80 characters 12 | #rule "MD014" # dollars signs not before commands w/o showing output 13 | rule "MD018" # must have space after header style 14 | rule "MD019" # no multiple spaces after header style 15 | rule "MD022" # headers should be surrounded by blank lines 16 | rule "MD023" # headers must start at the beginning of the line 17 | rule "MD024", :allow_different_nesting => true # no multiple same level headers with same content 18 | rule "MD025" # only 1 level 1 header 19 | rule "MD026", :punctuation => '.,;:' # no trailing punctuation in headers 20 | rule "MD027" # no multiple spaces after blockquote symbol 21 | rule "MD028" # no blank lines within blockquote 22 | #rule "MD029", :style => :ordered # ordered list item prefix, shoulded be ordered 23 | #rule "MD030", :ul_single => 1, :ol_single => 1, :ul_multi => 1, :ol_multi => 3 # spaces after list markers, controlled by prettier 24 | rule "MD031" # fenced code blocks need line surrounding 25 | rule "MD032" # lists should be surrounded by line 26 | rule "MD034" # no raw url 27 | rule "MD040" # Fenced code blocks should have a language specified 28 | rule "MD046", :style => :fenced # code block style - fenced 29 | -------------------------------------------------------------------------------- /test/files/si_examples.csv: -------------------------------------------------------------------------------- 1 | area,square meter,m^2 2 | volume,cubic meter,m^3 3 | speed,meter per second,m/s 4 | velocity,meter per second,m/s 5 | acceleration,meter per second squared,m/s^2 6 | wave number,reciprocal meter,m^-1 7 | mass density,kilogram per cubic meter,kg/m^3 8 | specific volume,cubic meter per kilogram,m^3/kg 9 | current density,ampere per square meter,A/m^2 10 | magnetic field strength,ampere per meter,A/m 11 | concentration,mole per cubic meter,mol/m^3 12 | luminance,candela per square meter,cd/m^2 13 | angular velocity,radian per second,rad/s 14 | angular acceleration,radian per second squared,rad/s^2 15 | dynamic viscosity,pascal second,Pa.s 16 | moment of force,newton meter per radian,N.m/rad 17 | surface tension,newton per meter,N/m 18 | heat flux density,watt per square meter,W/m^2 19 | radiant intensity,watt per steradian,W/sr 20 | radiance,watt per square meter steradian,W/(m^2.sr) 21 | heat capacity,joule per kelvin,J/K 22 | entropy,joule per kelvin,J/K 23 | specific heat,joule per kilogram kelvin,J/(kg.K) 24 | specific entropy,joule per kilogram kelvin,J/(kg.K) 25 | specific energy,joule per kilogram,J/kg 26 | thermal conductivity,watt per meter kelvin,W/(m.K) 27 | energy density,joule per cubic meter,J/m^3 28 | electric field strength,volt per meter,V/m 29 | electric charge density,coulomb per cubic meter,C/m^3 30 | electric flux density,coulomb per square meter,C/m^2 31 | permittivity,farad per meter,F/m 32 | permeability,henry per meter,H/m 33 | molar energy,joule per mole,J/mol 34 | molar entropy,joule per mole kelvin,J/(mol.K) 35 | exposure,coulomb per kilogram,C/kg 36 | rotational speed,revolution per minute,r/min 37 | catalytic concentration,katal per cubic meter,kat/m^3 38 | data rate,mebibit per second,Mib/s 39 | noise voltage density,nanovolt per root hertz,nV/Hz^(1/2) 40 | -------------------------------------------------------------------------------- /test/examples_test_windows.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019-2025, 3 | Lawrence Livermore National Security, LLC; 4 | See the top-level NOTICE for additional details. All rights reserved. 5 | SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | #include "units/units_decl.hpp" 8 | #include 9 | 10 | #include "units/units.hpp" 11 | #include "units/units_conversion_maps.hpp" 12 | 13 | /** @file Test just to load up some unit definitions and do some operations with 14 | them it tests linking and some usefulness in code coverage */ 15 | 16 | int main(int /*argc*/, char* /*argv*/[]) 17 | { 18 | units::fixed_precise_measurement fpm1(1250.0, units::precise::cm.pow(3)); 19 | units::fixed_precise_measurement fpm2(1.25, units::precise::L); 20 | if (fpm1 != fpm2) { 21 | return -1; 22 | } 23 | 24 | units::uncertain_measurement um1(1250.0, 25.0, units::cm.pow(3)); 25 | units::uncertain_measurement um2(1.25, 0.1, units::L); 26 | if (um1 != um2) { 27 | return -1; 28 | } 29 | 30 | units::measurement m1(1250.0, units::cm.pow(3)); 31 | if (m1 != 1.25 * units::L) { 32 | return -1; 33 | } 34 | 35 | units::fixed_measurement fm1(1250.0, units::cm.pow(3)); 36 | if (fm1 != 1.25 * units::L) { 37 | return -1; 38 | } 39 | 40 | units::precise_measurement pm1 = 41 | units::measurement_from_string("1250 cm^3"); 42 | if (pm1 != 1.25 * units::precise::L) { 43 | return -1; 44 | } 45 | 46 | units::precise_unit prec1(1.25, units::precise::L); 47 | 48 | if (prec1 != units::precise_unit(0.00125, units::precise::m.pow(3))) { 49 | return -1; 50 | } 51 | 52 | units::unit u1(1.25, units::L); 53 | 54 | if (u1 != units::unit(0.00125, units::m.pow(3))) { 55 | return -1; 56 | } 57 | return 0; 58 | } 59 | -------------------------------------------------------------------------------- /test/find_package_tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | # Copyright (c) 2017-2025, Battelle Memorial Institute; Lawrence Livermore 3 | # National Security, LLC; Alliance for Sustainable Energy, LLC. 4 | # See the top-level NOTICE for additional details. 5 | # All rights reserved. 6 | # 7 | # SPDX-License-Identifier: BSD-3-Clause 8 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 9 | 10 | cmake_minimum_required(VERSION 3.10...3.31) 11 | 12 | project(units-find-package-test) 13 | 14 | include(CTest) 15 | 16 | if(NOT UNITS_TARGET) 17 | set(UNITS_TARGET units) 18 | endif() 19 | 20 | # Test the HELICS CMake package config 21 | find_package(${UNITS_TARGET} 0.9 REQUIRED) 22 | 23 | # add some tests inside of the CMake 24 | 25 | message(STATUS "Binary location is ${PROJECT_BINARY_DIR}") 26 | # Test the CXX shared library target 27 | if(UNITS_BUILD_SHARED_LIBRARY) 28 | add_executable(shared-library-test-exe ../pkg_test_code/main.cpp) 29 | target_link_libraries(shared-library-test-exe ${UNITS_TARGET}::units) 30 | target_compile_definitions( 31 | shared-library-test-exe PUBLIC UNITS_LIB_HEADER="${UNITS_TARGET}/units.hpp" 32 | ) 33 | 34 | add_test(NAME shared-library-test COMMAND shared-library-test-exe) 35 | set_property(TEST shared-library-test PROPERTY PASS_REGULAR_EXPRESSION "10.7") 36 | 37 | endif() 38 | # Test the header only targets 39 | add_executable(header_only-exe ../pkg_test_code/header_only.cpp) 40 | target_link_libraries(header_only-exe ${UNITS_TARGET}::header_only) 41 | target_compile_definitions( 42 | header_only-exe PUBLIC UNITS_LIB_HEADER="${UNITS_TARGET}/units.hpp" 43 | ) 44 | add_test(NAME header_only-exe COMMAND header_only-exe) 45 | set_property(TEST header_only-exe PROPERTY PASS_REGULAR_EXPRESSION "PASS") 46 | -------------------------------------------------------------------------------- /docs/introduction/how.rst: -------------------------------------------------------------------------------- 1 | ===================================== 2 | How It Works 3 | ===================================== 4 | 5 | Given the design requirements the choice was how to make a class that could represent physical units. The desire for it to be a compact class drove the decision to somewhat limit what could be represented to physically realizable units. 6 | 7 | Unit Representation 8 | -------------------- 9 | 10 | The unit class consists of a multiplier and a representation of base units. 11 | The seven SI units + radians + currency units + count units. In addition a unit has 4 flags, per-unit for per unit or ratio units. One flag\[i_flag\] that is a representation of imaginary units, one flags for a variety of purposes and to differentiate otherwise similar units\[e_flag\]. And a flag to indicate an equation unit. Due to the requirement that the base units fit into a 4 byte type the represented powers of the units are limited. The list below shows the bit representation range and observed range of use in equations and observed usage 12 | 13 | - meter:\[-8,+7\] :normal range \[-4,+4\], intermediate ops \[-6,+6\] 14 | - kilogram:\[-4,+3\] :normal range \[-1,+1\], intermediate ops \[-2,+2\] 15 | - second:\[-8,+7\] :normal range \[-4,+4\], intermediate ops \[-6,+6\] 16 | - ampere:\[-4,+3\] :normal range \[-2,+2\] 17 | - kelvin:\[-4,+3\] :normal range \[-4,+1\] 18 | - mole:\[-2,+1\] :normal range \[-1,+1\] 19 | - candela:\[-2,+1\] :normal range \[-1,+1\] 20 | - currency:\[-2,+1\] :normal range \[-1,+1\] 21 | - count:\[-2,+1\] :normal range \[-1,+1\] 22 | - radians:\[-4,+3\] :normal range \[-2,+2\] 23 | 24 | These ranges were chosen to represent nearly all physical quantities that could be found in various disciplines we have encountered. 25 | 26 | 27 | - `SI units Publication guidelines `_ 28 | -------------------------------------------------------------------------------- /docs/user-guide/fixed_measurements.rst: -------------------------------------------------------------------------------- 1 | ==================== 2 | Fixed Measurements 3 | ==================== 4 | 5 | The primary difference between `fixed_measurement` and `measurement` is the idea that in a `fixed_measurement` the unit part is a constant. It does not change. Therefore any addition or subtraction operation will produce another measurement with the same units. It also allows for interaction and comparisons with numerical types since the unit is known. This is unlike measurements where comparison and addition and subtraction operations with numbers are not allowed. Otherwise the behavior and operations are identical between `measurement` and `fixed_measurement` and likewise between `fixed_precise_measurement` and `precise_measurement` 6 | 7 | Relationship with numbers 8 | -------------------------- 9 | Because the `unit` associated with a fixed measurement is fixed. It becomes legitimate to work with singular real valued numbers. 10 | 11 | 12 | .. code-block:: c++ 13 | 14 | fixed_measurement dist(10, m); 15 | 16 | if (dist>10.0) //this has meaning because the units of dist is known. 17 | { 18 | //all other operators are defined with doubles 19 | } 20 | 21 | dist=dist+3.0; // dist is now 13 meters 22 | 23 | dist-=2.0; // dist is now 11 meters 24 | 25 | dist=5.0; // dist is now 5 meters 26 | 27 | 28 | Interactions with `measurement` 29 | -------------------------------- 30 | 31 | Fixed measurements have an implicit conversion to :ref:`measurements`, so all the methods that work with measurement work with `fixed_measurements`. The construction of a fixed_measurement from measurement is explicit. Likewise fixed_precise_measurement` have an implicit conversion to `precise_measurement`, so all the methods that work with `precise_measurement` work with `fixed_precise_measurements`. The construction of a fixed_measurement from measurement is explicit. 32 | -------------------------------------------------------------------------------- /test/files/test_conversions/surface_tension_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. newton/meter [N/m]: 2 | 1 3 | 2. newton/centimeter [N/cm]: 4 | 0.01 5 | 3. newton/millimeter [N/mm]: 6 | 0.001 7 | 4. kilonewton/meter [kN/m]: 8 | 0.001 9 | 5. millinewton/millimeter: 10 | 1 11 | 6. millinewton/meter [mN/m]: 12 | 1000 13 | 7. millinewton/micrometer: 14 | 0.001 15 | 8. millinewton/nanometer: 16 | 0.000001 17 | 9. micronewton/millimeter: 18 | 1000 19 | 10. micronewton/micrometer: 20 | 1 21 | 11. micronewton/nanometer: 22 | 0.001 23 | 12. dyne/meter [dyn/m]: 24 | 100000 25 | 13. erg/square centimeter: 26 | 1000 27 | 14. erg/square millimeter: 28 | 10 29 | 15. gram-force/meter [gf/m]: 30 | 101.971621 31 | 16. gram-force/centimeter: 32 | 1.019716 33 | 17. gram-force/millimeter: 34 | 0.101972 35 | 18. gram-force/micrometer: 36 | 0.0001019716 37 | 19. gram-force/nanometer: 38 | 1.019716e-7 39 | 20. kilogram-force/meter: 40 | 0.101972 41 | 21. kilogram-force/centimeter: 42 | 0.0010197162 43 | 22. pond/meter: 44 | 101.971621 45 | 23. kilopond/meter [kp/m]: 46 | 0.101972 47 | 24. pound-force/meter [lbf/m]: 48 | 0.224809 49 | 25. ounce-force/meter [ozf/m]: 50 | 3.596943 51 | 26. poundal/meter [pdl/m]: 52 | 7.233014 53 | 27. poundal/yard [pdl/yd]: 54 | 6.613868 55 | 28. ounce-force/yard [ozf/yd]: 56 | 3.289045 57 | 29. ounce-force/foot [ozf/ft]: 58 | 1.096348253708 59 | 30. ounce-force/inch [ozf/in]: 60 | 0.09136235 61 | 31. pound-force/yard [lbf/yd]: 62 | 0.205565 63 | 32. kilogram-force/yard [kgf/yd]: 64 | 0.09324285 65 | 33. gram-force/yard [gf/yd]: 66 | 93.242851 67 | 34. gram-force/foot [gf/ft]: 68 | 31.08095017156 69 | 35. gram-force/inch [gf/in]: 70 | 2.590079 71 | 36. millinewton/yard [mN/yd]: 72 | 914.4 73 | 37. millinewton/foot [mN/ft]: 74 | 304.8 75 | 38. millinewton/inch [mN/in]: 76 | 25.4 77 | 39. kilonewton/yard [kN/yd]: 78 | 0.0009144 79 | 40. newton/yard [N/yd]: 80 | 0.9144 81 | 41. newton/foot [N/ft]: 82 | 0.3048 83 | 42. newton/inch [N/in]: 84 | 0.0254 -------------------------------------------------------------------------------- /.github/workflows/coverage.yml: -------------------------------------------------------------------------------- 1 | name: Coverage 2 | on: 3 | push: 4 | branches: 5 | - main 6 | pull_request: 7 | 8 | concurrency: 9 | group: ${{ github.workflow }}-${{ github.ref }} 10 | cancel-in-progress: true 11 | 12 | jobs: 13 | coverage: 14 | name: Coverage 15 | runs-on: ubuntu-latest 16 | strategy: 17 | matrix: 18 | std: ["11", "14", "17", "20"] 19 | unitBase: ["uint64_t", "uint32_t"] 20 | steps: 21 | - uses: actions/checkout@v6 22 | with: 23 | fetch-depth: 0 24 | 25 | - name: Get LCov 26 | run: | 27 | sudo apt-get install ca-certificates lcov 28 | #wget https://github.com/linux-test-project/lcov/releases/download/v2.2/lcov-2.2.tar.gz 29 | #tar -xzf lcov-2.2.tar.gz 30 | #cd lcov-2.2 31 | #sudo make install 32 | 33 | - name: Configure 34 | run: | 35 | cmake -S . -B build \ 36 | -DCMAKE_CXX_STANDARD=${{matrix.std}} \ 37 | -DUNITS_ENABLE_TESTS=ON \ 38 | -DUNITS_BASE_TYPE=${{matrix.unitBase}} \ 39 | -DCMAKE_BUILD_TYPE=Coverage 40 | 41 | - name: Build 42 | run: cmake --build build -j4 43 | 44 | - name: Test 45 | run: | 46 | cd build 47 | ctest --output-on-failure 48 | 49 | - name: Prepare coverage 50 | run: | 51 | lcov --ignore-errors gcov,mismatch --directory . --capture --output-file coverage.info 52 | lcov --remove coverage.info '*/test/*' '*gtest*' --output-file coverage.info 53 | lcov --list coverage.info 54 | working-directory: build 55 | 56 | - uses: codecov/codecov-action@v5 57 | with: 58 | files: build/coverage.info 59 | fail_ci_if_error: true 60 | functionalities: fixes 61 | token: ${{ secrets.CODECOV_TOKEN }} # required 62 | 63 | 64 | 65 | 66 | 67 | 68 | -------------------------------------------------------------------------------- /webserver/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2 | # Copyright (c) 2019-2025, 3 | # Lawrence Livermore National Security, LLC; 4 | # See the top-level NOTICE for additional details. All rights reserved. 5 | # SPDX-License-Identifier: BSD-3-Clause 6 | # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 7 | if(CMAKE_VERSION VERSION_GREATER 3.12) 8 | 9 | cmake_dependent_option( 10 | UNITS_BUILD_WEBSERVER 11 | "Build a unit webserver for unit string conversions, requires boost 1.70 or greater" 12 | OFF 13 | "CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME" 14 | OFF 15 | ) 16 | 17 | if(UNITS_BUILD_WEBSERVER) 18 | 19 | include(addBoost) 20 | add_executable(units_webserver unit_web_server.cpp) 21 | target_link_libraries( 22 | units_webserver PUBLIC ${UNITS_LC_PROJECT_NAME}::units compile_flags_target 23 | Boost::boost 24 | ) 25 | 26 | target_compile_definitions(units_webserver PUBLIC BOOST_DATE_TIME_NO_LIB) 27 | target_compile_definitions( 28 | units_webserver PUBLIC UNITS_VERSION_STRING="${UNITS_VERSION}" 29 | ) 30 | if(MSYS OR CYGWIN) 31 | target_link_libraries(units_webserver PUBLIC wsock32 ws2_32 iphlpapi) 32 | elseif(NOT WIN32) 33 | set(THREADS_PREFER_PTHREAD_FLAG ON) 34 | find_package(Threads REQUIRED) 35 | target_link_libraries(units_webserver PUBLIC Threads::Threads) 36 | endif() 37 | 38 | if(UNITS_INSTALL) 39 | install( 40 | TARGETS units_webserver ${UNITS_LIBRARY_EXPORT_COMMAND} 41 | DESTINATION "${CMAKE_INSTALL_BINDIR}" 42 | COMPONENT units_webserver 43 | ) 44 | endif() 45 | add_executable(${UNITS_LC_PROJECT_NAME}::units_webserver ALIAS units_webserver) 46 | endif() 47 | endif() 48 | -------------------------------------------------------------------------------- /test/files/test_conversions/radiation_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. RAD/second [RAD/s]: 2 | 1 3 | 2. RAD/millisecond [RAD/ms]: 4 | 0.001 5 | 3. RAD/microsecond [RAD/us]: 6 | 0.000001 7 | 4. RAD/nanosecond [RAD/ns]: 8 | 1e-9 9 | 5. RAD/minute [RAD/min]: 10 | 59.999999 11 | 6. RAD/hour [RAD/hr]: 12 | 3600 13 | 7. RAD/day [RAD/d]: 14 | 86400 15 | 8. RAD/week: 16 | 604800 17 | 9. RAD/month: 18 | 2628000 19 | 10. RAD/year [RAD/y]: 20 | 31536000 21 | 11. milliRAD/second [mRAD/s]: 22 | 1000 23 | 12. joule/kilogram/second: 24 | 0.01 25 | 13. joule/kilogram/millisecond: 26 | 0.00001 27 | 14. joule/kilogram/microsecond: 28 | 1e-8 29 | 15. joule/kilogram/nanosecond: 30 | 1e-11 31 | 16. joule/kilogram/minute: 32 | 0.6 33 | 17. joule/kilogram/hour [J/kg/hr]: 34 | 36 35 | 18. joule/kilogram/day [J/kg/d]: 36 | 864 37 | 19. joule/kilogram/week: 38 | 6048 39 | 20. joule/kilogram/month: 40 | 26280 41 | 21. joule/kilogram/year [J/kg/y]: 42 | 315360 43 | 22. joule/gram/second [J/g/s]: 44 | 0.00001 45 | 23. joule/gram/millisecond: 46 | 1e-8 47 | 24. joule/gram/microsecond: 48 | 1e-11 49 | 25. joule/gram/nanosecond: 50 | 1e-14 51 | 26. joule/milligram/second: 52 | 1e-8 53 | 27. joule/milligram/millisecond: 54 | 1e-11 55 | 28. joule/milligram/microsecond: 56 | 1e-14 57 | 29. joule/milligram/nanosecond: 58 | 1e-17 59 | 30. joule/milligram/minute: 60 | 6e-7 61 | 31. gray/second [Gy/s]: 62 | 0.01 63 | 32. gray/millisecond [Gy/ms]: 64 | 0.00001 65 | 33. gray/microsecond [Gy/us]: 66 | 1e-8 67 | 34. gray/nanosecond [Gy/ns]: 68 | 1e-11 69 | 35. gigagray/second [Ggy/s]: 70 | 1e-11 71 | 36. megagray/second [Mgy/s]: 72 | 1e-8 73 | 37. megagray/minute [Mgy/min]: 74 | 6e-7 75 | 38. kilogray/second [kGy/s]: 76 | 0.00001 77 | 39. centigray/second [cGy/s]: 78 | 1 79 | 40. milligray/second [mGy/s]: 80 | 10 81 | 41. microgray/second [uGy/s]: 82 | 10000 83 | 42. nanogray/second [nGy/s]: 84 | 10000000 85 | 43. picogray/second [pGy/s]: 86 | 1e+10 87 | 44. watt/kilogram [W/kg]: 88 | 0.01 89 | 45. sievert/second [Sv/s]: 90 | 0.01 91 | 46. rem/second [rem/s]: 92 | 1 -------------------------------------------------------------------------------- /test/files/test_conversions/conductivity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. siemens/meter [S/m]: 2 | 1 3 | 2. siemens/kilometer [S/km]: 4 | 1000 5 | 3. siemens/centimeter [S/cm]: 6 | 0.01 7 | 4. siemens/millimeter [S/mm]: 8 | 0.001 9 | 5. siemens/micrometer [S/um]: 10 | 0.000001 11 | 6. siemens/nanometer [S/nm]: 12 | 1e-9 13 | 7. megasiemens/meter [MS/m]: 14 | 0.000001 15 | 8. megasiemens/kilometer: 16 | 0.001 17 | 9. megasiemens/centimeter: 18 | 1e-8 19 | 10. megasiemens/millimeter: 20 | 1e-9 21 | 11. megasiemens/micrometer: 22 | 1e-12 23 | 12. megasiemens/nanometer: 24 | 1e-15 25 | 13. kilosiemens/meter [kS/m]: 26 | 0.001 27 | 14. kilosiemens/kilometer: 28 | 1 29 | 15. kilosiemens/centimeter: 30 | 0.00001 31 | 16. kilosiemens/millimeter: 32 | 0.000001 33 | 17. kilosiemens/micrometer: 34 | 1e-9 35 | 18. kilosiemens/nanometer: 36 | 1e-12 37 | 19. millisiemens/meter [mS/m]: 38 | 1000 39 | 20. microsiemens/meter [uS/m]: 40 | 1000000 41 | 21. microsiemens/centimeter: 42 | 10000 43 | 22. ampere/volt/meter [A/V/m]: 44 | 1 45 | 23. ampere/volt/kilometer: 46 | 1000 47 | 24. ampere/volt/centimeter: 48 | 0.01 49 | 25. ampere/volt/millimeter: 50 | 0.001 51 | 26. ampere/volt/micrometer: 52 | 0.000001 53 | 27. ampere/volt/nanometer: 54 | 1e-9 55 | 28. mho/meter: 56 | 1 57 | 29. gemmho/meter: 58 | 1000000 59 | 30. micromho/meter: 60 | 1000000 61 | 31. abmho/meter: 62 | 1e-9 63 | 32. abmho/millimeter: 64 | 1e-12 65 | 33. abmho/micrometer: 66 | 1e-15 67 | 34. abmho/nanometer: 68 | 1e-18 69 | 35. siemens/yard [S/yd]: 70 | 0.9144 71 | 36. siemens/foot [S/ft]: 72 | 0.3048 73 | 37. siemens/inch [S/in]: 74 | 0.0254 75 | 38. megasiemens/yard [MS/yd]: 76 | 9.144e-7 77 | 39. megasiemens/foot [MS/ft]: 78 | 3.048e-7 79 | 40. megasiemens/inch [MS/in]: 80 | 2.54e-8 81 | 41. kilosiemens/yard [kS/yd]: 82 | 0.0009144 83 | 42. kilosiemens/foot [kS/ft]: 84 | 0.0003048 85 | 43. kilosiemens/inch [kS/in]: 86 | 0.0000254 87 | 44. ampere/volt/yard [A/V/yd]: 88 | 0.9144 89 | 45. ampere/volt/foot [A/V/ft]: 90 | 0.3048 91 | 46. ampere/volt/inch [A/V/in]: 92 | 0.0254 -------------------------------------------------------------------------------- /test/files/test_conversions/angular_velocity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. degree/second: 2 | 57.295778 3 | 2. degree/millisecond: 4 | 0.05729578 5 | 3. degree/microsecond: 6 | 0.000057295778 7 | 4. degree/nanosecond: 8 | 5.729578e-8 9 | 5. degree/minute: 10 | 3437.746676 11 | 6. degree/hour: 12 | 206264.800574 13 | 7. degree/day: 14 | 4950355.21377 15 | 8. radian/second [rad/s]: 16 | 1 17 | 9. radian/millisecond [rad/ms]: 18 | 0.001 19 | 10. radian/microsecond [rad/us]: 20 | 1e-6 21 | 11. radian/nanosecond [rad/ns]: 22 | 1e-9 23 | 12. radian/minute [rad/min]: 24 | 60 25 | 13. radian/hour [rad/h]: 26 | 3600 27 | 14. radian/day [rad/d]: 28 | 86400 29 | 15. grad/second: 30 | 63.661975 31 | 16. grad/millisecond: 32 | 0.06366198 33 | 17. grad/microsecond: 34 | 0.000063661975 35 | 18. grad/nanosecond: 36 | 6.366198e-8 37 | 19. grad/minute: 38 | 3819.718529 39 | 20. grad/hour: 40 | 229183.111749 41 | 21. gon/second: 42 | 63.661975 43 | 22. gon/millisecond: 44 | 0.06366198 45 | 23. gon/microsecond: 46 | 0.000063661975 47 | 24. gon/nanosecond: 48 | 6.366198e-8 49 | 25. gon/minute: 50 | 3819.718529 51 | 26. gon/hour: 52 | 229183.111749 53 | 27. arcminute/second: 54 | 3437.746676 55 | 28. arcminute/millisecond: 56 | 3.437747 57 | 29. arcminute/microsecond: 58 | 0.0034377467 59 | 30. arcminute/nanosecond: 60 | 0.000003437747 61 | 31. arcminute/minute: 62 | 206264.800574 63 | 32. arcminute/hour: 64 | 12375888.034424 65 | 33. arcminute/day: 66 | 2.970213e+8 67 | 34. arcsecond/second: 68 | 206264.800574 69 | 35. arcsecond/millisecond: 70 | 206.264801 71 | 36. arcsecond/microsecond: 72 | 0.206265 73 | 37. arcsecond/nanosecond: 74 | 0.0002062648 75 | 39. mil(angle)/second: 76 | 1018.591608 77 | 40. circle/second: 78 | 0.159155 79 | 41. circle/millisecond: 80 | 0.0001591549 81 | 42. circle/microsecond: 82 | 1.591549e-7 83 | 43. circle/nanosecond: 84 | 1.591549e-10 85 | 44. circle/minute: 86 | 9.549296 87 | 45. circle/hour: 88 | 572.957779 89 | 46. circle/day: 90 | 13750.986705 91 | 47. circle/week: 92 | 96256.906934 93 | 49. circle/year: 94 | 5019110.147294 -------------------------------------------------------------------------------- /FuzzTargets/fuzz_target_from_string.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019-2025, 3 | Lawrence Livermore National Security, LLC; 4 | See the top-level NOTICE for additional details. All rights reserved. 5 | SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include "units/units.hpp" 9 | #include 10 | #include 11 | 12 | static const bool cflag = []() { 13 | units::disableCustomCommodities(); 14 | return true; 15 | }(); 16 | 17 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) 18 | { 19 | if (Size == 0) { 20 | return 0; 21 | } 22 | std::string test1(reinterpret_cast(Data), Size); 23 | auto unit1 = units::unit_from_string(test1); 24 | if (!is_error(unit1)) { 25 | auto str = units::to_string(unit1); 26 | auto u2 = units::unit_from_string(str); 27 | if (units::is_error(u2)) { 28 | throw(6u); 29 | } 30 | bool match = false; 31 | if (units::unit_cast(u2) == units::unit_cast(unit1)) { 32 | match = true; 33 | } else if (units::isnormal(root(u2, 2))) { 34 | if (root(units::unit_cast(u2), 2) == 35 | root(units::unit_cast(unit1), 2)) { 36 | match = true; 37 | } 38 | } 39 | if (!match) { 40 | if (units::isnormal(root(u2, 3))) { 41 | if (root(units::unit_cast(u2), 3) == 42 | root(units::unit_cast(unit1), 3)) { 43 | match = true; 44 | } 45 | } 46 | } 47 | if (!match) { 48 | if (std::isnormal(u2.multiplier()) && 49 | std::isnormal(unit1.multiplier())) { 50 | throw(5.0); 51 | } else if (u2.base_units() != unit1.base_units()) { 52 | throw(7); 53 | } else { 54 | throw("nan"); 55 | } 56 | } 57 | } 58 | // its::clearCustomCommodities(); 59 | return 0; // Non-zero return values are reserved for future use. 60 | } 61 | -------------------------------------------------------------------------------- /test/files/test_conversions/angular_accel_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. degree/square second: 2 | 1 3 | 2. degree/square millisecond: 4 | 0.000001 5 | 3. degree/square microsecond: 6 | 1e-12 7 | 4. degree/square nanosecond: 8 | 1e-18 9 | 5. degree/square minute: 10 | 3599.999856 11 | 6. degree/square hour: 12 | 12960000 13 | 7. degree/square day: 14 | 7.46496e+9 15 | 11. radian/square second: 16 | 0.01745329 17 | 12. radian/square millisecond: 18 | 1.745329e-8 19 | 13. radian/square microsecond: 20 | 1.745329e-14 21 | 14. radian/square nanosecond: 22 | 1.745329e-20 23 | 15. radian/square minute: 24 | 62.831852 25 | 16. radian/square hour [rad/h2]: 26 | 226194.67728 27 | 17. radian/square day [rad/d2]: 28 | 1.302881e+8 29 | 21. grad/square second: 30 | 1.111111 31 | 22. grad/square millisecond: 32 | 0.000001111111 33 | 23. grad/square microsecond: 34 | 1.111111e-12 35 | 24. grad/square nanosecond: 36 | 1.111111e-18 37 | 25. gon/square second: 38 | 1.111111 39 | 26. arcminute/square second: 40 | 60 41 | 27. arcminute/square millisecond: 42 | 0.00006 43 | 28. arcminute/square microsecond: 44 | 6e-11 45 | 29. arcminute/square nanosecond: 46 | 6e-17 47 | 30. arcsecond/square second: 48 | 3600 49 | 31. arcsecond/square millisecond: 50 | 0.0036 51 | 32. arcsecond/square microsecond: 52 | 3.6e-9 53 | 33. arcsecond/square nanosecond: 54 | 3.6e-15 55 | 44. mil(angle)/square second: 56 | 17.774618 57 | 45. mil(angle)/square millisecond: 58 | 0.000017774618 59 | 46. mil(angle)/square microsecond: 60 | 1.777462e-11 61 | 47. mil(angle)/square nanosecond: 62 | 1.776199e-17 63 | 48. mil(angle)/square minute: 64 | 63988.62424 65 | 49. mil(angle)/square hour: 66 | 2.30359e+8 67 | 50. mil(angle)/square day: 68 | 1.33e+11 69 | 54. revolution/square second: 70 | 0.0027777778 71 | 55. revolution/square millisecond: 72 | 2.777778e-9 73 | 56. revolution/square microsecond: 74 | 2.777778e-15 75 | 57. revolution/square nanosecond: 76 | 2.777778e-21 77 | 58. revolution/square minute: 78 | 10 79 | 59. revolution/square hour: 80 | 36000 81 | 60. revolution/square day: 82 | 20736000 83 | 64. circle/square second: 84 | 0.0027777778 85 | -------------------------------------------------------------------------------- /test/files/UDUNITS2/UDUNITS2_COPYRIGHT.txt: -------------------------------------------------------------------------------- 1 | Copyright 2014 University Corporation for Atmospheric Research and contributors. 2 | All rights reserved. 3 | 4 | This software was developed by the Unidata Program Center of the 5 | University Corporation for Atmospheric Research (UCAR) 6 | . 7 | 8 | Redistribution and use in source and binary forms, with or without modification, 9 | are permitted provided that the following conditions are met: 10 | 11 | 1) Redistributions of source code must retain the above copyright notice, 12 | this list of conditions and the following disclaimer. 13 | 2) Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 3) Neither the names of the development group, the copyright holders, nor the 17 | names of contributors may be used to endorse or promote products derived 18 | from this software without specific prior written permission. 19 | 4) This license shall terminate automatically and you may no longer exercise 20 | any of the rights granted to you by this license as of the date you 21 | commence an action, including a cross-claim or counterclaim, against 22 | the copyright holders or any contributor alleging that this software 23 | infringes a patent. This termination provision shall not apply for an 24 | action alleging patent infringement by combinations of this software with 25 | other software or hardware. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 29 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS 30 | OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 31 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE. 33 | -------------------------------------------------------------------------------- /test/test_random_round_trip.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019-2025, 3 | Lawrence Livermore National Security, LLC; 4 | See the top-level NOTICE for additional details. All rights reserved. 5 | SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include "test.hpp" 9 | #include "units/units.hpp" 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | using namespace units; 17 | 18 | // these tests only make sense if the base type size is 4 bytes(which is the 19 | // default) 20 | TEST(randomRoundTrip, basic) 21 | { 22 | if (sizeof(UNITS_BASE_TYPE) == 4) { 23 | std::default_random_engine engine( 24 | std::chrono::system_clock::now().time_since_epoch().count()); 25 | std::uniform_int_distribution distribution( 26 | 0, std::numeric_limits::max()); 27 | 28 | for (auto ii = 0; ii < 6000; ++ii) { 29 | auto start = distribution(engine); 30 | detail::unit_data unitdata(nullptr); 31 | memcpy(static_cast(&unitdata), &start, 4); 32 | auto startunit = unit(unitdata); 33 | auto str = to_string(startunit); 34 | auto resunit = unit_cast(unit_from_string(str)); 35 | EXPECT_EQ(startunit, resunit) << "round trip failed " << start; 36 | } 37 | } 38 | } 39 | 40 | struct rtrip : public ::testing::TestWithParam {}; 41 | 42 | TEST_P(rtrip, testConversions) 43 | { 44 | if (sizeof(UNITS_BASE_TYPE) == 4) { 45 | unsigned int start = GetParam(); 46 | detail::unit_data unitdata(nullptr); 47 | memcpy(static_cast(&unitdata), &start, 4); 48 | auto startunit = unit(unitdata); 49 | auto str = to_string(startunit); 50 | auto resunit = unit_cast(unit_from_string(str)); 51 | EXPECT_EQ(startunit, resunit) << "round trip failed " << start; 52 | } 53 | } 54 | 55 | const std::vector customList{0, 545404204, 484372462, 1504872254}; 56 | 57 | INSTANTIATE_TEST_SUITE_P(spotChecks, rtrip, ::testing::ValuesIn(customList)); 58 | -------------------------------------------------------------------------------- /test/files/test_conversions/pressure_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. pascal [pa]: 2 | 100 3 | 2. exapascal [Epa]: 4 | 1e-16 5 | 3. petapascal [Ppa]: 6 | 1e-13 7 | 4. terapascal [Tpa]: 8 | 1e-10 9 | 5. gigapascal [Gpa]: 10 | 1e-7 11 | 6. megapascal [Mpa]: 12 | 0.0001 13 | 7. kilopascal [kPa]: 14 | 0.1 15 | 8. hectopascal [hPa]: 16 | 1 17 | 9. dekapascal [daPa]: 18 | 10 19 | 10. decipascal [dPa]: 20 | 1000 21 | 11. centipascal [cPa]: 22 | 10000 23 | 12. millipascal [mPa]: 24 | 100000 25 | 13. micropascal [uPa]: 26 | 100000000 27 | 14. nanopascal [nPa]: 28 | 1e+11 29 | 15. picopascal [pPa]: 30 | 1e+14 31 | 16. femtopascal [fPa]: 32 | 1e+17 33 | 17. attopascal [aPa]: 34 | 1e+20 35 | 18. newton/square meter [N/m2]: 36 | 100 37 | 19. newton/square centimeter: 38 | 0.01 39 | 20. newton/square millimeter: 40 | 0.0001 41 | 21. kilonewton/square meter: 42 | 0.1 43 | 22. bar: 44 | 0.001 45 | 23. millibar [mbar]: 46 | 1 47 | 24. microbar [ubar]: 48 | 1000 49 | 25. dyne/square centimeter: 50 | 1000 51 | 26. kilogram-force/square meter: 52 | 10.197162 53 | 27. kilogram-force/square centimeter: 54 | 0.0010197 55 | 28. kilogram-force/square millimeter: 56 | 0.0000102 57 | 29. gram-force/square centimeter: 58 | 1.019716 59 | 30. ton-force(metric)/square meter: 60 | 0.0101972 61 | 31. ton-force (short)/square foot: 62 | 0.0010443 63 | 32. ton-force (short)/square inch: 64 | 0.0000072518 65 | 33. ton-force (long)/square foot: 66 | 0.0009324 67 | 34. ton-force (long)/square inch: 68 | 0.000006475 69 | 35. poundal/square foot [pdl/ft2]: 70 | 67.196898 71 | 36. psi [psi]: 72 | 0.0145038 73 | 37. pound-force/square inch: 74 | 0.0145038 75 | 38. kip-force/square inch: 76 | 0.0000145038 77 | 39. ksi [ksi]: 78 | 0.0000145038 79 | 41. kip-force/square foot: 80 | 0.0020885472 81 | 42. pound-force/square foot: 82 | 2.088547 83 | 43. pound-force/square yard: 84 | 18.796925 85 | 44. kip-force/square yard: 86 | 0.01879692 87 | 45. torr [torr]: 88 | 0.750062 89 | 48. inch mercury [inHg]: 90 | 0.0295301 91 | 52. inch water [inH2O]: 92 | 0.401474 93 | 53. foot water [ftH2O]: 94 | 0.0334562 95 | 56. atmosphere technical[att]: 96 | 0.0010197162 97 | 57. Standard atmosphere [atm]: 98 | 0.0009869233 -------------------------------------------------------------------------------- /test/files/test_conversions/surface_charge_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. coulomb/square meter: 2 | 1 3 | 2. coulomb/square decimeter: 4 | 0.01 5 | 3. coulomb/square centimeter: 6 | 0.0001 7 | 4. coulomb/square millimeter: 8 | 0.000001 9 | 5. coulomb/square micrometer: 10 | 1e-12 11 | 6. coulomb/square nanometer: 12 | 1e-18 13 | 7. kilocoulomb/square meter: 14 | 0.001 15 | 8. millicoulomb/square meter: 16 | 1000 17 | 9. millicoulomb/square millimeter: 18 | 0.001 19 | 10. millicoulomb/square micrometer: 20 | 1e-9 21 | 11. millicoulomb/square nanometer: 22 | 1e-15 23 | 12. microcoulomb/square nanometer: 24 | 1e-12 25 | 13. nanocoulomb/square nanometer: 26 | 1e-9 27 | 14. picocoulomb/square nanometer: 28 | 0.000001 29 | 15. elementary charge/square nanometer: 30 | 6.25 31 | 16. faraday/square meter: 32 | 0.00001036427 33 | 18. franklin/square meter: 34 | 2.994012e+9 35 | 19. megacoulomb/square meter: 36 | 0.000001 37 | 20. megacoulomb/square kilometer: 38 | 1 39 | 21. statcoulomb/square nanometer: 40 | 2.99e-9 41 | 22. abcoulomb/square nanometer: 42 | 1e-19 43 | 23. ampere hour/square meter: 44 | 0.0002777778 45 | 24. ampere hour/square decimeter: 46 | 0.000002777778 47 | 25. ampere hour/square centimeter: 48 | 2.777778e-8 49 | 26. ampere minute/square meter: 50 | 0.01666667 51 | 27. ampere minute/square decimeter: 52 | 0.0001666667 53 | 28. ampere second/square meter: 54 | 1 55 | 29. coulomb/square yard [C/yd2]: 56 | 0.83592 57 | 30. coulomb/square foot [C/ft2]: 58 | 0.09288 59 | 31. coulomb/square inch [C/in2]: 60 | 0.000645 61 | 32. kilocoulomb/square yard: 62 | 0.00083592 63 | 33. millicoulomb/square yard: 64 | 835.92 65 | 34. millicoulomb/square foot: 66 | 92.88 67 | 35. millicoulomb/square inch: 68 | 0.645 69 | 36. megacoulomb/square mile: 70 | 2.589346 71 | 37. megacoulomb/square yard: 72 | 8.3612735999999996e-07 73 | 38. ampere hour/square yard: 74 | 0.0002322576 75 | 39. ampere hour/square foot: 76 | 0.0000258064 77 | 40. ampere hour/square inch: 78 | 1.792111e-7 79 | 41. ampere minute/square yard: 80 | 0.01393546 81 | 42. ampere minute/square foot: 82 | 0.001548384 83 | 43. ampere minute/square inch: 84 | 0.000010752667 85 | 44. ampere second/square inch: 86 | 0.00064516 -------------------------------------------------------------------------------- /docs/user-guide/math_operations.rst: -------------------------------------------------------------------------------- 1 | ======================= 2 | Math Operations 3 | ======================= 4 | 5 | Additional mathematical operations on measurements are available in the `unit_math.hpp` header these are header only so no additional compilation is required. The intention of this header is to match operations from the `cmath` header available in the standard library. These are all template functions which will work for any measurement type. 6 | 7 | Type traits 8 | ---------------------- 9 | 10 | The header includes a few type traits used in the header file and potentially useful elsewhere including 11 | 12 | - `is_unit` : true if the type is a unit (unit or precise_unit) 13 | - `is_measurement` : true if the type is one of the defined measurement types 14 | - `is_precise_measurement` : true if the type is one of the defined precise measurement type 15 | 16 | Rounding and Truncation 17 | ------------------------- 18 | These operations will effect only the value part of the measurement 19 | 20 | - `round` 21 | - `trunc` 22 | - `ceil` 23 | - `floor` 24 | 25 | Trigonometric functions 26 | ------------------------- 27 | 28 | Trigonometric operations will operate only if the measurement is convertible to radians 29 | 30 | - `sin` 31 | - `cos` 32 | - `tan` 33 | 34 | Multiplies and divides 35 | ------------------------------- 36 | 37 | Division and multiplication operators for measurements that have support for per_unit measurement 38 | 39 | - `multiplies` : works like `*` except when one of the measurements is per_unit and they have the same unit base, then they remove the per unit 40 | - `divides` : works like `/` except if both measurements have the same base then the result has a `per_unit` unit 41 | 42 | See :ref:`strain` for examples on usage 43 | 44 | Others 45 | --------- 46 | 47 | Other common mathematical expressions found in `` 48 | 49 | - `fmod` : return the floating point modulus of a division operation as long as division is a valid operation 50 | - `hypot` : works for two and three measurements or floating point values as long as addition is a valid operation. 51 | - `cbrt` : works similarly to the `sqrt` operation 52 | -------------------------------------------------------------------------------- /docs/web/index.rst: -------------------------------------------------------------------------------- 1 | ================== 2 | Units on the Web 3 | ================== 4 | 5 | You can try out the string conversions through the units 6 | `Webserver <../_static/convert.html>`_ 7 | 8 | This page allows you to enter a measurement string and a unit string for conversion. 9 | 10 | The measurement string can be of any form with a number and units 11 | 12 | - `10 m` 13 | - `hundred pounds` 14 | - `45.673 GB` 15 | - `dozen feet` 16 | 17 | the unit string should be some unit that is convertible from the measurement units: 18 | 19 | - `inches` 20 | - `troy oz` 21 | - `kiB` 22 | - `british fathoms` 23 | 24 | The conversion also supports mathematical operations see :ref:`Units From Strings` for additional details on string conversions. The units can also be set to `*`or `` to convert the measurement to base units. 25 | 26 | Rest API 27 | ----------- 28 | 29 | The units web server does not serve files, it generates all responses on the fly. There are 3 URI indicators it responds to beyond the root page. 30 | 31 | - `/convert` : responds with an html page 32 | - `/convert_trivial` : responds with the results as a simple text 33 | - `/convert_json` : responds with a json string containing the requested conversions and the results. 34 | 35 | For example in Linux or anything with curl 36 | 37 | .. code-block:: bash 38 | 39 | $ curl -s "13.52.135.81/convert_trivial?measurement=10%20tons&units=lb" 40 | 20000 41 | 42 | $ curl -s "13.52.135.81/convert_json?measurement=10%20tons&units=lb" 43 | { 44 | "request_measurement":"", 45 | "request_units":"lb"", 46 | "measurement":"", 47 | "units":"lb"", 48 | "value":"nan" 49 | } 50 | 51 | $ curl -s "13.52.135.81/convert_json?measurement=ten%20meterspersecond&units=feetperminute&caction=to_string" 52 | { 53 | "request_measurement":"ten meterspersecond", 54 | "request_units":"feetperminute", 55 | "measurement":"10 m/s", 56 | "units":"ft/min", 57 | "value":"1968.5" 58 | } 59 | 60 | This works with POST or GET methods. The `caction` field can be set to "to_string" this will "simplify" the units in the result or at least use the internal to_string operations to convert to an interpretable string in more accessible units. 61 | -------------------------------------------------------------------------------- /FuzzTargets/fuzz_target_measurement_from_string.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2019-2025, 3 | Lawrence Livermore National Security, LLC; 4 | See the top-level NOTICE for additional details. All rights reserved. 5 | SPDX-License-Identifier: BSD-3-Clause 6 | */ 7 | 8 | #include "units/units.hpp" 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | static const bool cflag = []() { 15 | units::disableCustomCommodities(); 16 | return true; 17 | }(); 18 | 19 | extern "C" int LLVMFuzzerTestOneInput(const uint8_t* Data, size_t Size) 20 | { 21 | if (Size == 0) { 22 | return 0; 23 | } 24 | std::string test1(reinterpret_cast(Data), Size); 25 | 26 | auto meas1 = units::measurement_from_string(test1); 27 | if (isnormal(meas1)) { 28 | auto str = to_string(meas1); 29 | auto meas2 = units::measurement_from_string(str); 30 | if (!meas2.units().has_same_base(meas1.units()) && !isnormal(meas2)) { 31 | throw(6u); 32 | } 33 | bool match = (meas1 == meas2); 34 | if (!match) { 35 | auto mc1 = units::measurement_cast(meas1); 36 | auto mc2 = units::measurement_cast(meas2); 37 | match = (mc1 == mc2); 38 | 39 | if (!match && isnormal(root(meas2, 2))) { 40 | match = (root(mc2, 2) == root(mc1, 2)); 41 | } 42 | if (!match && isnormal(root(meas2, 3))) { 43 | match = (root(mc2, 3) == root(mc1, 3)); 44 | } 45 | if (!match && !(isnormal(mc1) && isnormal(mc2))) { 46 | auto uc1 = unit_cast(meas1.as_unit()); 47 | auto uc2 = unit_cast(meas2.as_unit()); 48 | match = (uc1 == uc2); 49 | } 50 | } 51 | if (!match) { 52 | if (meas1.units() == meas2.units()) { 53 | throw(std::invalid_argument( 54 | "measurement and conversion don't match but units do")); 55 | } 56 | throw(std::invalid_argument( 57 | "measurement and conversion don't match, units do not match")); 58 | } 59 | } 60 | // its::clearCustomCommodities(); 61 | return 0; // Non-zero return values are reserved for future use. 62 | } 63 | -------------------------------------------------------------------------------- /test/files/test_conversions/energy_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. joule [J]: 2 | 10.5 3 | 2. gigajoule [GJ]: 4 | 1.05e-8 5 | 3. megajoule [MJ]: 6 | 0.0000105 7 | 4. kilojoule [kJ]: 8 | 0.0105 9 | 5. millijoule [mJ]: 10 | 10500 11 | 6. microjoule [uJ]: 12 | 10500000 13 | 7. nanojoule [nJ]: 14 | 1.05e+10 15 | 8. attojoule [aJ]: 16 | 1.05e+19 17 | 9. erg: 18 | 1.05e+8 19 | 10. dyne centimeter [dyn.cm]: 20 | 1.05e+8 21 | 11. newton meter [N.m]: 22 | 10.5 23 | 12. megaelectron-volt [MeV]: 24 | 6.552e+13 25 | 13. kiloelectron-volt [keV]: 26 | 6.552e+16 27 | 14. electron-volt [eV]: 28 | 6.552e+19 29 | 15. watt-second [W.s]: 30 | 10.5 31 | 16. gigawatt-hour [GW.h]: 32 | 2.916667e-12 33 | 17. megawatt-hour [MW.h]: 34 | 2.916667e-9 35 | 18. kilowatt-hour [kwh]: 36 | 0.000002916667 37 | 19. kilowatt-second [kW.s]: 38 | 0.0105 39 | 20. watt-hour [W.h]: 40 | 0.0029166667 41 | 21. horsepower hour [hp.h]: 42 | 0.0000039165 43 | 22. horsepower (metric) hour: 44 | 0.000003969 45 | 23. kilocalorie (IT): 46 | 0.002507883 47 | 24. kilocalorie (th) [kcal (th)]: 48 | 0.002509563 49 | 25. MMKcal: 50 | 2.5095e-9 51 | 26. calorie (IT): 52 | 2.507883 53 | 27. calorie (th) [cal (th)]: 54 | 2.50956 55 | 28. calorie (nutritional): 56 | 2.507883 57 | 29. kilocalorie (nutritional): 58 | 0.002507883 59 | 30. Btu (IT) [Btu]: 60 | 0.0099520785 61 | 31. Btu (th) [Btu (th)]: 62 | 0.009958746 63 | 32. Mbtu: 64 | 0.000009952079 65 | 33. mega Btu (IT) [MMBtu]: 66 | 9.952079e-9 67 | 34. ton-hour (refrigeration): 68 | 8.295e-7 69 | 35. fuel oil equivalent of 1 kiloliter: 70 | 2.6145e-10 71 | 36. fuel oil equivalent of 1 barrel: 72 | 1.6485e-9 73 | 37. gigaton [Gton]: 74 | 2.5095e-18 75 | 38. megaton [Mton]: 76 | 2.5095e-15 77 | 39. kiloton [kton]: 78 | 2.5095e-12 79 | 40. ton (explosives): 80 | 2.5095e-9 81 | 41. poundal foot [pdl.ft]: 82 | 249.168785 83 | 42. gram-force meter [gf.m]: 84 | 1070.702024 85 | 43. gram-force centimeter: 86 | 107070.202365 87 | 44. kilogram-force centimeter: 88 | 107.070202 89 | 45. kilogram-force meter: 90 | 1.070702 91 | 46. kilopond meter [kp.m]: 92 | 1.070702 93 | 47. ounce-force inch [ozf.in]: 94 | 1486.925293 95 | 48. pound-force foot [lbf.ft]: 96 | 7.744403 97 | 49. pound-force inch [lbf.in]: 98 | 92.932831 99 | 50. therm (EC): 100 | 9.952078e-8 101 | 51. therm (US): 102 | 9.954456e-8 -------------------------------------------------------------------------------- /docs/introduction/converter.rst: -------------------------------------------------------------------------------- 1 | ===================================== 2 | Converter App 3 | ===================================== 4 | 5 | As a simple example and potentially useful tool we made the converter app. It is a command line application that can be built as part of the units library to convert units given on the command line. 6 | 7 | .. code-block:: bash 8 | 9 | $ ./unit_convert 10 m ft 10 | 32.8084 11 | 12 | $ ./unit_convert ten meters per second mph 13 | 22.3694 14 | 15 | $ ./unit_convert --full ten meters per second mph 16 | ten meters per second = 22.3694 mph 17 | 18 | $ ./unit_convert --simplified ten meters per second miles/hour 19 | 10 m/s = 22.3694 mph 20 | 21 | $ ./unit_convert -s four hundred seventy-three kilograms per hour pounds/min 22 | 473 kg/hr = 17.3798 lb/min 23 | 24 | $ ./unit_convert -s 22 british fathoms * 25 | 10 british fathoms = 18.288 m 26 | 27 | 28 | basically there are two options `--full,-f` and `--simplified,-s` a measurement which will take an arbitrary number of strings and a final string as a unit to convert to. It outputs the conversion and if specified the surrounding measurement and units either simplified or in the original. Using `*` or `` in place of the unit string will result in converting the measurement to base units. 29 | 30 | .. code-block:: bash 31 | 32 | $ ./unit_convert --help 33 | application to perform a conversion of a value from one unit to another 34 | Usage: unit_convert [OPTIONS] measure... convert 35 | 36 | Positionals: 37 | measure [TEXT ...] ... REQUIRED 38 | measurement to convert .e.g '57.4 m', 'two thousand GB' '45.7*22.2 feet^3/s^2' 39 | convert TEXT REQUIRED the units to convert the measurement to 40 | 41 | Options: 42 | -h,--help Print this help message and exit 43 | -f,--full specify that the output should include the measurement and units 44 | -s,--simplified simplify the units using the units library to_string functions and print the conversion string like full. This option will take precedence over --full 45 | --measurement [TEXT ...] ... REQUIRED 46 | measurement to convert .e.g '57.4 m', 'two thousand GB' '45.7*22.2 feet^3/s^2' 47 | --convert TEXT REQUIRED the units to convert the measurement to 48 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | exclude: ^(ThirdParty/|test/files/|.github/workflows/|.github/actions/) 2 | repos: 3 | - repo: https://github.com/jumanjihouse/pre-commit-hooks 4 | rev: 3.0.0 5 | hooks: 6 | - id: markdownlint 7 | args: [-s, ./config/.markdownlintrc] 8 | - id: script-must-have-extension 9 | - repo: https://github.com/cheshirekow/cmake-format-precommit 10 | rev: v0.6.13 11 | hooks: 12 | - id: cmake-format 13 | - repo: https://github.com/Lucas-C/pre-commit-hooks-nodejs 14 | rev: v1.1.2 15 | hooks: 16 | - id: dockerfile_lint 17 | args: [--rulefile, ./config/docker_rules.yml, --dockerfile] 18 | - repo: https://github.com/pre-commit/mirrors-prettier 19 | rev: v4.0.0-alpha.8 20 | hooks: 21 | - id: prettier 22 | - repo: https://github.com/psf/black-pre-commit-mirror 23 | rev: 25.12.0 24 | hooks: 25 | - id: black 26 | args: ["--line-length=100"] 27 | - repo: https://github.com/asottile/blacken-docs 28 | rev: 1.20.0 29 | hooks: 30 | - id: blacken-docs 31 | additional_dependencies: [black==24.10] 32 | - repo: https://github.com/Lucas-C/pre-commit-hooks 33 | rev: v1.5.5 34 | hooks: 35 | - id: remove-tabs 36 | - repo: https://github.com/codespell-project/codespell 37 | rev: v2.4.1 38 | hooks: 39 | - id: codespell 40 | exclude: ^(test/|units/|docs/reference/) 41 | args: 42 | [ 43 | "-w", 44 | "--skip=*.csv", 45 | "--ignore-words=./config/spelling_whitelist.txt", 46 | "--exclude-file=./config/spelling_ignorelines.txt", 47 | ] 48 | - repo: https://github.com/pre-commit/pre-commit-hooks 49 | rev: v6.0.0 50 | hooks: 51 | - id: mixed-line-ending 52 | - id: trailing-whitespace 53 | - id: check-merge-conflict 54 | - id: check-case-conflict 55 | - id: check-yaml 56 | args: ["--allow-multiple-documents"] 57 | - id: end-of-file-fixer 58 | - id: check-shebang-scripts-are-executable 59 | - repo: https://github.com/pre-commit/mirrors-clang-format 60 | rev: v21.1.7 61 | hooks: 62 | - id: clang-format 63 | types_or: [c++, c] 64 | - repo: local 65 | hooks: 66 | - id: disallow-caps 67 | name: Disallow improper capitalization 68 | language: pygrep 69 | entry: PyBind|Numpy|Cmake|CCache|PyTest|Github 70 | exclude: .pre-commit-config.yaml 71 | -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["scikit-build-core >=0.10", "nanobind >=2.5.0"] 3 | 4 | build-backend = "scikit_build_core.build" 5 | 6 | [project] 7 | name = "units_llnl" 8 | version = "0.13.1" 9 | description = "Python bindings for the LLNL units library" 10 | readme = "python/README.md" 11 | requires-python = ">=3.10" 12 | license = "BSD-3-Clause" 13 | license-files = [ 14 | "LICENSE", 15 | "NOTICE" 16 | ] 17 | authors = [ 18 | { name = "Philip Top", email = "top1@llnl.gov" }, 19 | ] 20 | classifiers = [ 21 | "Programming Language :: Python :: 3", 22 | "Operating System :: OS Independent", 23 | "Topic :: Scientific/Engineering", 24 | "Development Status :: 4 - Beta", 25 | ] 26 | keywords = [ 27 | "units", 28 | "measurement", 29 | "power systems", 30 | "co-simulation", 31 | "commodities", 32 | "science", 33 | "python", 34 | ] 35 | [project.urls] 36 | Homepage = "https://github.com/llnl/units" 37 | Documentation = "https://units.readthedocs.io/en/latest/" 38 | Repository = "https://github.com/llnl/units" 39 | Issues = "https://github.com/LLNL/units/issues" 40 | Changelog = "https://github.com/LLNL/units/blob/main/CHANGELOG.md" 41 | 42 | 43 | [project.optional-dependencies] 44 | test = ["pytest"] 45 | 46 | [tool.scikit-build] 47 | # Protect the configuration against future changes in scikit-build-core 48 | minimum-version = "build-system.requires" 49 | 50 | # Setuptools-style build caching in a local directory 51 | build-dir = "build/{wheel_tag}" 52 | 53 | # The build targets to use when building the project. Empty builds the default 54 | # target. 55 | build.targets = ["units_llnl_ext"] 56 | 57 | # The components to install. If empty, all default components are installed. 58 | install.components = [] 59 | 60 | # Build stable ABI wheels for CPython 3.12+ 61 | wheel.py-api = "cp312" 62 | # require a recent version of cmake 63 | cmake.version = ">=3.26.1" 64 | 65 | # ensure the python extension gets built 66 | cmake.args = ["-DUNITS_BUILD_PYTHON_LIBRARY=ON", "-DUNITS_ENABLE_TESTS=OFF"] 67 | 68 | [tool.cibuildwheel] 69 | # Necessary to see build output from the actual compilation 70 | build-verbosity = 1 71 | skip = "pp311-macosx_arm64" 72 | 73 | # Run pytest to ensure that the package was correctly built 74 | test-command = "pytest {project}/test/python" 75 | test-requires = "pytest" 76 | 77 | # Needed for full C++17 support 78 | [tool.cibuildwheel.macos.environment] 79 | MACOSX_DEPLOYMENT_TARGET = "11.0" 80 | -------------------------------------------------------------------------------- /docs/index.rst: -------------------------------------------------------------------------------- 1 | .. units documentation master file, created by 2 | sphinx-quickstart on Fri Jan 17 16:04:22 2020. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | ************************************************************* 7 | Welcome to The units library user guide and documentation! 8 | ************************************************************* 9 | 10 | The Units library provides a means of working with units of measurement at runtime, including conversion to and from strings. It provides a small number of types for working with units and measurements and operations necessary for user input and output with units. 11 | 12 | This software was developed for use in `LLNL/GridDyn `_, and `HELICS `_ and is currently a work in progress (though getting close). Namespaces, function names, and code organization is subject to change though is fairly stable at this point, input is welcome. 13 | 14 | |codecov| |Azure| |Circle CI| |License| 15 | 16 | .. |codecov| image:: https://codecov.io/gh/LLNL/units/branch/main/graph/badge.svg 17 | :target: https://codecov.io/gh/LLNL/units 18 | 19 | .. |Azure| image:: https://dev.azure.com/phlptp/units/_apis/build/status/LLNL.units?branchName=main 20 | :target: https://dev.azure.com/phlptp/units/_build/latest?definitionId=1&branchName=main 21 | 22 | .. |Circle CI| image:: https://circleci.com/gh/LLNL/units.svg?style=svg 23 | :target: https://circleci.com/gh/LLNL/units 24 | 25 | .. |License| image:: https://img.shields.io/badge/License-BSD-blue.svg 26 | :target: https://github.com/GMLC-TDC/HELICS-src/blob/main/LICENSE 27 | 28 | The :ref:`Introduction` is a discussion about the why? and How the library came together and a generally what it does and how it was tested. 29 | The :ref:`Installation and Linking` guide is a discussion about linking and using the library, and the :ref:`User Guide` is the 30 | how-to about how to use the software library. For the details see :ref:`Details` and to try out some of the string conversions check out :ref:`Units on the Web` 31 | Finally :ref:`Application Notes` contains some discussions on particular applications and usages. 32 | 33 | .. toctree:: 34 | :maxdepth: 1 35 | :caption: Basics 36 | 37 | introduction/index 38 | installation/index 39 | user-guide/index 40 | application_notes/index 41 | details/index 42 | web/index 43 | -------------------------------------------------------------------------------- /test/files/test_conversions/distance_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. meter [m]: 2 | 1 3 | 2. kilometer [km]: 4 | 0.001 5 | 3. centimeter [cm]: 6 | 100 7 | 4. millimeter [mm]: 8 | 1000 9 | 5. micrometer [um]: 10 | 1000000 11 | 6. micron: 12 | 1000000 13 | 7. nanometer [nm]: 14 | 1e+9 15 | 8. picometer [pm]: 16 | 1e+12 17 | 9. decimeter [dm]: 18 | 10 19 | 10. nautical league (international): 20 | 0.0001799856 21 | 11. nautical mile (international): 22 | 0.0005399568 23 | 12. inch [in]: 24 | 39.370079 25 | 13. yard [yd]: 26 | 1.093613 27 | 14. foot [ft]: 28 | 3.28084 29 | 15. league [lea]: 30 | 0.0002071237 31 | 16. mile [mi]: 32 | 0.0006213712 33 | 17. light year [ly]: 34 | 1.06e-16 35 | 18. exameter [Em]: 36 | 1e-18 37 | 19. petameter [Pm]: 38 | 1e-15 39 | 20. terameter [Tm]: 40 | 1e-12 41 | 21. gigameter [Gm]: 42 | 1e-9 43 | 22. megameter [Mm]: 44 | 0.000001 45 | 23. hectometer [hm]: 46 | 0.01 47 | 24. dekameter [dam]: 48 | 0.1 49 | 25. femtometer [fm]: 50 | 1e+15 51 | 26. attometer: 52 | 1e+18 53 | 27. parsec [pc]: 54 | 3.24e-17 55 | 28. astronomical unit [AU]: 56 | 6.68e-12 57 | 30. mil: 58 | 39370.07874 59 | 31. microinch: 60 | 39370078.739999 61 | 32. nautical league (UK): 62 | 0.0001798706 63 | 33. nautical mile (UK): 64 | 0.0005396118 65 | 35. furlong [fur]: 66 | 0.0049709695 67 | 36. chain [ch]: 68 | 0.0497097 69 | 38. rod [rd]: 70 | 0.198839 71 | 39. perch: 72 | 0.198839 73 | 40. pole: 74 | 0.198839 75 | 41. fathom [fath]: 76 | 0.546807 77 | 42. link [li]: 78 | 4.97097 79 | 43. cubit (UK): 80 | 2.187227 81 | 44. hand: 82 | 9.84252 83 | 45. span (cloth): 84 | 4.374453 85 | 46. finger (cloth): 86 | 8.748906 87 | 47. nail (cloth): 88 | 17.497813 89 | 49. ken: 90 | 0.550055 91 | 50. caliber: 92 | 3937.007874 93 | 51. centiinch: 94 | 3937.007874 95 | 52. pica: 96 | 236.220472 97 | 53. point: 98 | 2834.645669 99 | 54. twip: 100 | 56692.913386 101 | 55. barleycorn: 102 | 118.110236 103 | 56. inch (US Survey): 104 | 39.37 105 | 57. league (statute) [lea (US)]: 106 | 0.0002071233 107 | 58. mile (statute) [mi (US)]: 108 | 0.0006213699 109 | 59. foot (US Survey) [ft (US)]: 110 | 3.280833 111 | 60. link (US Survey) [li (US)]: 112 | 4.97096 113 | 63. angstrom: 114 | 1e+10 115 | 65. x-unit [X]: 116 | 9.98e+12 117 | 66. fermi: 118 | 1e+15 119 | 67. arpent: 120 | 0.01708771 121 | 73. long cubit: 122 | 1.874766 123 | 74. li (Chinese): 124 | 0.002 125 | 75. zhang (Chinese): 126 | 0.3 127 | 76. chi (Chinese): 128 | 3 129 | 77. cun (Chinese): 130 | 30 -------------------------------------------------------------------------------- /test/files/test_conversions/resistivity_conversions.txt: -------------------------------------------------------------------------------- 1 | 1. ohm meter [ohm.m]: 2 | 1000 3 | 2. ohm kilometer [ohm.km]: 4 | 1 5 | 3. ohm centimeter [ohm.cm]: 6 | 100000 7 | 4. ohm millimeter [ohm.mm]: 8 | 1000000 9 | 5. ohm micrometer [ohm.um]: 10 | 1e+9 11 | 6. ohm nanometer [ohm.nm]: 12 | 1e+12 13 | 7. milliohm meter [mohm.m]: 14 | 1000000 15 | 8. milliohm centimeter [mohm.cm]: 16 | 100000000 17 | 9. milliohm millimeter [mohm.mm]: 18 | 1e+9 19 | 10. milliohm micrometer [mohm.um]: 20 | 1e+12 21 | 11. milliohm nanometer [mohm.nm]: 22 | 1e+15 23 | 12. kiloohm meter [Kohm.m]: 24 | 1 25 | 13. kiloohm kilometer [Kohm.km]: 26 | 0.001 27 | 14. megaohm meter [Mohm.m]: 28 | 0.001 29 | 15. microohm meter [uohm.m]: 30 | 1e+9 31 | 16. microohm centimeter [uohm.cm]: 32 | 1e+11 33 | 17. microohm millimeter [uohm.mm]: 34 | 1e+12 35 | 18. microohm micrometer [uohm.um]: 36 | 1e+15 37 | 19. microohm nanometer [uohm.nm]: 38 | 1e+18 39 | 20. volt/ampere meter [V/A.m]: 40 | 1000 41 | 21. volt/ampere kilometer: 42 | 1 43 | 22. volt/ampere centimeter: 44 | 100000 45 | 23. volt/ampere millimeter: 46 | 1000000 47 | 24. volt/ampere micrometer: 48 | 1e+9 49 | 25. volt/ampere nanometer: 50 | 1e+12 51 | 26. meter/siemens [m/S]: 52 | 1000 53 | 27. kilometer/siemens [km/S]: 54 | 1 55 | 28. centimeter/siemens [cm/S]: 56 | 100000 57 | 29. millimeter/siemens [mm/S]: 58 | 1000000 59 | 30. micrometer/siemens [um/S]: 60 | 1e+9 61 | 31. nanometer/siemens [nm/S]: 62 | 1e+12 63 | 32. abohm meter: 64 | 1e+12 65 | 33. abohm centimeter: 66 | 1e+14 67 | 34. abohm millimeter: 68 | 1e+15 69 | 35. abohm micrometer: 70 | 1e+18 71 | 36. abohm nanometer: 72 | 1e+21 73 | 41. statohm micrometer: 74 | 0.00111 75 | 42. statohm nanometer: 76 | 1.11 77 | 44. ohm yard [ohm.yd]: 78 | 1093.613298 79 | 45. ohm foot [ohm.ft]: 80 | 3280.839895 81 | 46. ohm inch [ohm.in]: 82 | 39370.07874 83 | 47. kiloohm yard [Kohm.yd]: 84 | 1.093613 85 | 48. kiloohm foot [Kohm.ft]: 86 | 3.28084 87 | 49. kiloohm inch [Kohm.in]: 88 | 39.370079 89 | 50. megaohm yard [Mohm.yd]: 90 | 0.0010936133 91 | 51. megaohm foot [Mohm.ft]: 92 | 0.0032808399 93 | 52. megaohm inch [Mohm.in]: 94 | 0.03937008 95 | 53. volt/ampere yard [V/A.yd]: 96 | 1093.613298 97 | 54. volt/ampere foot [V/A.ft]: 98 | 3280.839895 99 | 55. volt/ampere inch [V/A.in]: 100 | 39370.07874 101 | 56. kiloohm mile [Kohm.mi]: 102 | 0.0006213712 103 | 57. yard/siemens [yd/S]: 104 | 1093.613298 105 | 58. foot/siemens [ft/S]: 106 | 3280.839895 107 | 59. inch/siemens [in/S]: 108 | 39370.07874 --------------------------------------------------------------------------------