#ifndef RYU_COMMON_H
#define RYU_COMMON_H
#include <stdint.h>
#include <string.h>
#include <stdbool.h>
#define assert(x)
#if __SIZEOF_POINTER__ == 4
#define RYU_32_BIT_PLATFORM
#endif
#ifdef __SIZEOF_INT128__
#define HAS_UINT128
#endif
#if __SIZEOF_DOUBLE__ == 8
#define RYU64 double
#elif __SIZEOF_LONG_DOUBLE__ == 8
#define RYU64 long double
#endif
static inline int
max_int(int a, int b)
{
return a > b ? a : b;
}
static inline int
min_int(int a, int b)
{
return a < b ? a : b;
}
int32_t __log2pow5(const int32_t e);
#define log2pow5(e) __log2pow5(e)
int32_t __ceil_log2pow5(const int32_t e);
#define ceil_log2pow5(e) __ceil_log2pow5(e)
int32_t __pow5bits(const int32_t e);
#define pow5bits(e) __pow5bits(e)
uint32_t __log10Pow2(const int32_t e);
#define log10Pow2(e) __log10Pow2(e)
uint32_t __log10Pow5(const int32_t e);
#define log10Pow5(e) __log10Pow5(e)
static inline uint32_t
float_to_bits(const float f)
{
uint32_t bits = 0;
memcpy(&bits, &f, sizeof(float));
return bits;
}
#ifdef RYU64
static inline uint64_t
ryu64_to_bits(const RYU64 d)
{
uint64_t bits = 0;
memcpy(&bits, &d, sizeof(d));
return bits;
}
#endif
#define DOUBLE_POW5_INV_BITCOUNT 125
#define DOUBLE_POW5_BITCOUNT 125
void __double_computePow5(const uint32_t i, uint64_t * const result);
void __double_computeInvPow5(const uint32_t i, uint64_t * const result);
#endif