32 lines
581 B
C
32 lines
581 B
C
#ifndef DI_DRV_SQRTF_H_
|
|
#define DI_DRV_SQRTF_H_
|
|
#include <stdint.h>
|
|
#include <math.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Set a float from a 32 bit int. */
|
|
#define SET_FLOAT_WORD(d, w) \
|
|
do { \
|
|
union {float f; uint32_t i; } __u; \
|
|
__u.i = (uint32_t)(w); \
|
|
(d) = __u.f; \
|
|
} while (0)
|
|
|
|
/* Get a 32 bit int from a float. */
|
|
#define GET_FLOAT_WORD(w, d) \
|
|
do { \
|
|
union {float f; uint32_t i; } __u; \
|
|
__u.f = (d); \
|
|
(w) = (int32_t)__u.i; \
|
|
} while (0)
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
/** @} */
|
|
#endif /* DI_DRV_SQRTF_H__ */
|