fpm icon indicating copy to clipboard operation
fpm copied to clipboard

Use types larger than 32bit

Open GMellar opened this issue 1 year ago • 5 comments

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?

GMellar avatar Sep 09 '23 14:09 GMellar

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?

MikeLankamp avatar Sep 11 '23 05:09 MikeLankamp

Does this mean at the moment a Q48.16 is not possible?

peterson79 avatar Sep 20 '23 16:09 peterson79

For most common platforms, yes, it's not possible at the moment.

MikeLankamp avatar Sep 20 '23 16:09 MikeLankamp

If you're using gcc, you can use __int128_t

id01 avatar Nov 04 '23 23:11 id01

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.

SirNate0 avatar Dec 29 '23 02:12 SirNate0