fpm
fpm copied to clipboard
Use types larger than 32bit
I was wondering how to use larger base types for example Q32.16 and use all the multiplication and division routines. Is there any plan to support this?
Hi @GMellar, at the moment fpm
supports any native integer type as base and intermediate type. However, unless your compiler defines a 128-bit integer type (for fpm
's intermediate type), it's not possible to define a 64-bit fixed-point type.
There is an open request (#8) to support e.g. boost::multiprecision::cpp_int
which would solve this.
Does this answer your question?
Does this mean at the moment a Q48.16 is not possible?
For most common platforms, yes, it's not possible at the moment.
If you're using gcc, you can use __int128_t
For me, I had to define
// in namespace std
template <>
struct is_signed<__int128_t>: std::true_type{};
for it to work. But I was able to use a 64bit fixed point type with that.