-
Notifications
You must be signed in to change notification settings - Fork 85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use types larger than 32bit #57
Comments
Hi @GMellar, at the moment There is an open request (#8) to support e.g. 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. |
For GCC you should be able to use already mentioned For MSVC, there are many comments about "no 128-bit support" but... there is You may be able to use code like #if defined(FPM_INT128)
// Already defined
#elif defined(__SIZEOF_INT128__)
using int128_t = __int128_t;
#define FPM_INT128 ::fpm::int128_t
#elif defined(_WIN32) && defined(_MSC_VER)
using int128_t = std::_Signed128;
#define FPM_INT128 ::fpm::int128_t
#else
#warning 128-bit numbers not supported.
#endif
#ifdef FPM_INT128
static_assert(sizeof(FPM_INT128) > sizeof(std::int64_t));
static_assert(std::is_signed<FPM_INT128>::value);
using fixed_56_8 = fixed<std::int64_t, FPM_INT128, 8>;
using fixed_48_16 = fixed<std::int64_t, FPM_INT128, 16>;
using fixed_32_32 = fixed<std::int64_t, FPM_INT128, 32>;
using fixed_16_48 = fixed<std::int64_t, FPM_INT128, 48>;
using fixed_8_56 = fixed<std::int64_t, FPM_INT128, 56>;
#endif I've put it after "Convenience typedefs" block of |
@AbitTheGray I'm afraid it's not working, there are two issues:
@MikeLankamp from this error, I found the comments in the code:
But I don't know the meaning of "there's only one integral bit", can I change the type 'IntermediateType' to 'BaseType' if I only use 24:8 or 48:16 fpm numbers? It'll work if change that but I don't know if it will lead to some calculation errors... Updated: I tested to change the IntermediateType to BaseType and it seems work well. |
That comment is relevant e.g. when you use a 1.31 fixed point type with a base type of
Yes. |
@MikeLankamp got it, thanks for your explanation!
plus you need to comment on the static checks that lead to errors. |
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?
The text was updated successfully, but these errors were encountered: