### use uint32_t to ensure alignment in union, improve comments

parent fdb1fcc6
Pipeline #1304 passed with stage
in 347 minutes and 57 seconds
 ... ... @@ -772,10 +772,11 @@ defined, there is a "te_xpix" field in objects, not a "te_xpos" as before: */ typedef union { t_float f; unsigned int ui; uint32_t ui; }t_bigorsmall32; static inline int PD_BADFLOAT(t_float f) // test for NANs, infs and denormals /* Test strictly for NANs and infs */ static inline int PD_BADFLOAT(t_float f) { t_bigorsmall32 pun; pun.f = f; ... ... @@ -783,7 +784,13 @@ static inline int PD_BADFLOAT(t_float f) // test for NANs, infs and denormals return((pun.ui == 0) | (pun.ui == 0x7f800000)); } static inline int PD_BIGORSMALL(t_float f) // > abs(2^64) or < abs(2^-64) /* Test to find unusually large or small normal values, in addition to denormals, NANs and infs: f > abs(2^65) or < abs(2^-63) This is useful for catching extreme values in, say, a filter, then bashing to zero before ever calculating a denormal. */ static inline int PD_BIGORSMALL(t_float f) { t_bigorsmall32 pun; pun.f = f; ... ... @@ -795,10 +802,11 @@ static inline int PD_BIGORSMALL(t_float f) // > abs(2^64) or < abs(2^-64) typedef union { t_float f; unsigned int ui; uint32_t ui; }t_bigorsmall64; static inline int PD_BADFLOAT(t_float f) // test for NANs, infs and denormals /* Test for NANs and infs */ static inline int PD_BADFLOAT(t_float f) { t_bigorsmall64 pun; pun.f = f; ... ... @@ -806,7 +814,13 @@ static inline int PD_BADFLOAT(t_float f) // test for NANs, infs and denormals return((pun.ui == 0) | (pun.ui == 0x7ff00000)); } static inline int PD_BIGORSMALL(t_float f) // > abs(2^512) or < abs(2^-512) /* Test to find unusually large or small normal values, in addition to denormals, NANs and infs: f > abs(2^513) or < abs(2^-511) This is useful for catching extreme values in, say, a filter, then bashing to zero before ever calculating a denormal. */ static inline int PD_BIGORSMALL(t_float f) { t_bigorsmall64 pun; pun.f = f; ... ...
• Line 789: f > abs(2^65) or < abs(2^-63)

I think this should be abs(f) >= 2^65 or < 2^-63

same problem at line 819

• Developer

Just a remark: unsigned int will always be a 32 bit integer, on just about any conceivable system where Purr Data will be able to run on. I'm wondering, though, whether using uint32_t might be a portability issue. Are we guaranteed to include the proper headers so that it is available, on all Un*x platforms at least?

Edited by Albert Gräf
• Owner

It passed CI under Windows msys2 which I assume means it found stdint.h ok there.

What Un*x doesn't have stdint.h?

• Developer

Right, it's (at least) in ISO/IEC 9899:1999 and POSIX 2003, so we should be good there.

Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!