{"id":31288985,"url":"https://github.com/johnmcfarlane/cnl","last_synced_at":"2026-01-18T16:06:18.519Z","repository":{"id":22959511,"uuid":"97791424","full_name":"johnmcfarlane/cnl","owner":"johnmcfarlane","description":"A Compositional Numeric Library for C++","archived":false,"fork":false,"pushed_at":"2024-04-26T09:47:30.000Z","size":8890,"stargazers_count":683,"open_issues_count":79,"forks_count":69,"subscribers_count":26,"default_branch":"main","last_synced_at":"2026-01-11T17:53:22.809Z","etag":null,"topics":["arithmetic","cmake","cpp","deterministic","embedded","fixed-point","multiprecision","precision","safe","simulation"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/johnmcfarlane.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE_1_0.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2017-07-20T04:45:57.000Z","updated_at":"2025-12-30T04:54:31.000Z","dependencies_parsed_at":"2024-01-08T21:18:52.844Z","dependency_job_id":null,"html_url":"https://github.com/johnmcfarlane/cnl","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/johnmcfarlane/cnl","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmcfarlane%2Fcnl","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmcfarlane%2Fcnl/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmcfarlane%2Fcnl/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmcfarlane%2Fcnl/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/johnmcfarlane","download_url":"https://codeload.github.com/johnmcfarlane/cnl/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/johnmcfarlane%2Fcnl/sbom","scorecard":{"id":528684,"data":{"date":"2025-08-11","repo":{"name":"github.com/johnmcfarlane/cnl","commit":"7b6172f3d657147964079e91d078302d853419c5"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":1,"reason":"0 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/deploy.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Warn: no topLevel permission defined: .github/workflows/wide-integer.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Info: Possibly incomplete results: error parsing job operating system: .github/workflows/test.yml:178","Info: Possibly incomplete results: error parsing job operating system: .github/workflows/test.yml:191","Info: Possibly incomplete results: error parsing job operating system: .github/workflows/test.yml:196","Info: Possibly incomplete results: error parsing job operating system: .github/workflows/test.yml:200","Info: Possibly incomplete results: error parsing job operating system: .github/workflows/test.yml:211","Info: Possibly incomplete results: error parsing job operating system: .github/workflows/test.yml:214","Info: Possibly incomplete results: error parsing job operating system: .github/workflows/test.yml:218","Info: Possibly incomplete results: error parsing job operating system: .github/workflows/test.yml:224","Info: Possibly incomplete results: error parsing shell code: reached EOF without closing quote `: .github/workflows/test.yml:284","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/deploy.yml:17: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/deploy.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:423: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:437: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:440: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:23: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:162: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:165: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:185: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:398: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:255: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:258: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:309: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:323: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:351: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:354: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:411: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/test.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/wide-integer.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/johnmcfarlane/cnl/wide-integer.yml/main?enable=pin","Info:   0 out of  16 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE_1_0.txt:0","Info: FSF or OSI recognized license: Boost Software License 1.0: LICENSE_1_0.txt:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 15 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T05:08:11.585Z","repository_id":22959511,"created_at":"2025-08-20T05:08:11.585Z","updated_at":"2025-08-20T05:08:11.585Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28533742,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-18T00:39:45.795Z","status":"online","status_checked_at":"2026-01-18T02:00:07.578Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arithmetic","cmake","cpp","deterministic","embedded","fixed-point","multiprecision","precision","safe","simulation"],"created_at":"2025-09-24T13:01:54.331Z","updated_at":"2026-01-18T16:06:18.501Z","avatar_url":"https://github.com/johnmcfarlane.png","language":"C++","readme":"# Compositional Numeric Library\n\n[![push](https://github.com/johnmcfarlane/cnl/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/johnmcfarlane/cnl/actions/workflows/test.yml)\n\nThe Compositional Numeric Library (CNL) is a C++ library of fixed-precision\nnumeric classes which enhance integers to deliver safer, simpler, cheaper\narithmetic types. Documentation can be found [here](http://johnmcfarlane.github.io/cnl/).\nYou can try out CNL on Compiler Explorer [here](https://godbolt.org/z/vzdvYzeqW).\n\nCNL is particularly well-suited to:\n\n* compute or energy-constrained environments where FPUs are absent or costly;\n* compute or energy-intensive environments where arithmetic is the bottleneck\n  such as simulations, machine learning applications and DSPs; and\n* domains such as finance where precision is essential.\n\n## Requirements\n\nThe latest version of CNL requires a C++20-compatible tool chain.\n([Version 1.x](https://github.com/johnmcfarlane/cnl/tree/v1.x) supports C++11.)\nCNL is continually tested on the following systems:\n\n### Linux\n\nTested:\n\n* GCC 10, 11, 12\n* Clang 10, 11, 12, 13, 14\n* libstdc++ 10, 11, 12\n* libc++ 13, 14\n* [CMake](https://cmake.org/download/) 3.23.1\n* Conan 1.48.1\n\n### OS X\n\nTested:\n\n* GCC 11 / Clang 13\n* [CMake](https://cmake.org/download/) 3.23.1\n* Conan 1.48.1\n\n### Windows\n\nTested:\n\n* Visual Studio 2019 Version 16 (19.29.30145.0)\n* Visual Studio 2022 Version 17 (19.32.31329.0)\n* [CMake](https://cmake.org/download/) 3.23.1\n* Conan 1.48.1\n\n## Instructions\n\n### Build\n\nCMake scripts are provided.\n\n* To build and install CNL on your system:\n\n```sh\nmkdir build \u0026\u0026 cd build\ncmake ..\ncmake --build . --target install\n```\n\nNote: you may need user privileges to install the library.\nAlternatively, you can install to user directory using [`CMAKE_INSTALL_PREFIX`](https://cmake.org/cmake/help/latest/variable/CMAKE_INSTALL_PREFIX.html#cmake-install-prefix):\n\n```sh\nmkdir build \u0026\u0026 cd build\ncmake -DCMAKE_INSTALL_PREFIX:FILE=/home/username/someplace ..\ncmake --build . --target install\n```\n\nAlternatively, CNL is a header-only library so you can simply point to the\n_include_ directory\n\n```sh\nc++ -isystem /path/to/cnl/include -std=c++20 my_program.cpp\n```\n\nor even include the root header directly in your code:\n\n```c++\n#include \"/path/to/cnl/include/cnl/all.h\"\n```\n\n### Test\n\nThe test suite uses CMake and depends on Google Test and Google Benchmark.\nOptional integration tests use Boost.Multiprecision.\n\n1. Conan can be used to pull in essential dependencies.\n   This example assumes GCC but other tool chain files are provided:\n\n   ```shell\n   cd build\n   conan profile new --detect --force default\n   conan profile update settings.compiler.libcxx=libstdc++11 default  # GCC/Clang only\n   conan profile update env.CONAN_CMAKE_TOOLCHAIN_FILE=../test/toolchain/gcc.cmake default # GCC only\n   conan install --build=missing --options test=unit ..\n   ```\n\n   ... and then configure, build and run unit tests:\n\n   ```shell\n   conan build --configure --build --test ..\n   ```\n\n1. To run benchmarks, use `--options test=benchmark`...\n\n   ```shell\n   conan install --build=missing --options test=benchmark ..\n   ```\n\n   then configure and build\n\n   ```shell\n   conan build --configure --build ..\n   ```\n\n   and finally run explicitly to see the results.\n\n   ```shell\n   ./test/benchmark/test-benchmark\n   ```\n\n### Integration\n\nThe API is exposed through headers in the [include](./include/) directory.\nAdd this to your system header list and include, e.g.:\n\n```c++\n// to use a specific type:\n#include \u003ccnl/scaled_integer.h\u003e\n\n// or to include all CNL types:\n#include \u003ccnl/all.h\u003e\n```\n\n## Example Projects\n\nExamples of projects using CNL:\n\n* [CDSP](https://github.com/hbe72/cdsp) - Compositional DSP Library for\n  C++;\n* [BrewBlox firmware](https://github.com/BrewBlox/brewblox-firmware) - firmware\n  for a brewery controller\n* [cnl_example](https://github.com/johnmcfarlane/cnl_example) - minimal\n  CMake-based project which uses CNL as a dependency.\n\n## Further Reading\n\n* CNL [documentation](http://johnmcfarlane.github.io/cnl/)\n* CppCon 2017 [presentation](https://youtu.be/GEfmV3Xcuok)\n* Embedded Artistry [article](https://embeddedartistry.com/blog/2017/8/25/c11-fixed-point-arithemetic-library)\n* ISO C++ papers:\n  * [P0037](http://wg21.link/p0037) - Fixed-Point Real Numbers\n  * [P0554](http://wg21.link/p0554) - Composition of Arithmetic Types\n  * [P0827](http://wg21.link/p0827) - General-Purpose Constant Value Type\n  * [P0828](http://wg21.link/p0828) - Elastic Integers\n  * [P1050](http://wg21.link/p1050) - Fractional Numeric Type\n\n## Alternatives\n\n* Much of the simplicity and efficiency in CNL's API design can be traced back\n  to Matheus Izvekov's [fp](https://github.com/mizvekov/fp) fixed point library.\n* Together with Lawrence Crowl's fixed-point paper, [P0106](https://wg21.link/p0106r0),\n  it lays the groundwork for integer-backed real number approximation that minimizes\n  loss of performance and precision.\n* [fpm](https://github.com/MikeLankamp/fpm) is a fixed-point math library with a\n  high quantity of mathematical functions.\n* [Fixed Point Class](https://www.codeproject.com/Articles/37636/Fixed-Point-Class)\n  is a single-header C++98 solution from Peter Schregle's.\n\n## Contact Information\n\nAll feedback greatly appreciated.\n\n* [CNL Issues](https://github.com/johnmcfarlane/cnl/issues)\n* [cnl@john.mcfarlane.name](mailto:cnl@john.mcfarlane.name)\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnmcfarlane%2Fcnl","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjohnmcfarlane%2Fcnl","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjohnmcfarlane%2Fcnl/lists"}