https://github.com/dkosmari/libfxd
libfxd is a fixed-point library for C++20.
https://github.com/dkosmari/libfxd
cplusplus cplusplus-20 fixed-point numerics
Last synced: 10 months ago
JSON representation
libfxd is a fixed-point library for C++20.
- Host: GitHub
- URL: https://github.com/dkosmari/libfxd
- Owner: dkosmari
- License: apache-2.0
- Created: 2023-03-20T13:11:18.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-26T02:37:32.000Z (over 2 years ago)
- Last Synced: 2025-01-03T07:34:35.320Z (12 months ago)
- Topics: cplusplus, cplusplus-20, fixed-point, numerics
- Language: C++
- Homepage: https://dkosmari.github.io/libfxd/
- Size: 1.5 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: COPYING.APL
- Authors: AUTHORS
Awesome Lists containing this project
README
libfxd - a fixed-point library for C++
======================================
libfxd is a C++20 headers-only library that implements fixed-point types as a templated
class. It's licensed under the Apache Public License 2.0 (see the file `COPYING.APL`).
Installation
------------
Since it's a headers-only library, no compilation is necessary; the compiler just needs to
locate the headers using an option like `-I /path/to/libfxd/include`.
To install the headers, use the standard Automake procedure:
./configure --prefix=/usr
make
sudo make install
See the `INSTALL` file and/or run `./configure --help` for more details.
If the source code was checked out from the repository, you may need to first run the
`bootstrap` script to create the `configure` script.
Usage
-----
Sample program:
```cpp
#include
#include
int main()
{
using F = fxd::fixed<20, 12>;
F a = 5;
F b = 2.5;
F c;
std::cout << "Enter a value: ";
std::cin >> c;
F d = (a + b + c) / 3;
std::cout << "Average: " << d << std::endl;
std::cout << "which has raw value: " << d.raw_value << std::endl;
}
```
Documentation is available in the `doc` directory in .md text files (using Markdown
syntax.) If Doxygen is available, it will be automatically built inside `doc/html`.
Examples can be found in the `examples` directory.