libfxd 0.2.dev
A fixed-point library for C++.
Loading...
Searching...
No Matches
basic.cpp
#include <iostream>
#include <fxd/fxd.hpp> // include everything
int main()
{
using F = fxd::fixed<20, 12>;
F a = 5; // construct from integer
F b = 2.5; // construct from floating point
F c; // uninitialized
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;
using F2 = fxd::fixed<10, 10>;
auto x = a < F2{5};
std::cout << x << std::endl;
}
Includes all of libfxd headers.
The fixed-point class template.
Definition: fixed.hpp:38
raw_type raw_value
The raw value, stored as a bitfield.
Definition: fixed.hpp:65