#ifndef __GINKGO_FLOAT_H
#define __GINKGO_FLOAT_H

#define FLT_ROUNDS (__Ginkgo_flt_rounds())
#define FLT_EVAL_METHOD 0
#define FLT_RADIX       2

#define FLT_HAS_SUBNORM 1
#define DBL_HAS_SUBNORM 1
#define LDBL_HAS_SUBNORM 1

// only works on little endian machines
#define FLT_SNAN (((union { int i; float f; }){ 0x7FA00000 }).f)
#define DBL_SNAN (((union { long l; double d; }){ 0x7FF4000000000000 }).d)
#define LDBL_SNAN (((union { long l[2]; long double d; }){ { 0xA0, 0xFF7F000000000000 } }).d)

#define INFINITY (((union { int i; float f; }){ 0x7F800000 }).f)
#define NAN (((union { int i; float f; }){ 0x7FC00000 }).f)

#define FLT_MANT_DIG    24
#define DBL_MANT_DIG    53
#define LDBL_MANT_DIG   64

#define FLT_DECIMAL_DIG     9
#define DBL_DECIMAL_DIG     17
#define LDBL_DECIMAL_DIG    21

#define DECIMAL_DIG 21

#define FLT_DIG     6
#define DBL_DIG     15
#define LDBL_DIG    18

#define FLT_MIN_EXP     (-125)
#define DBL_MIN_EXP     (-1021)
#define LDBL_MIN_EXP    (-16381)

#define FLT_MIN_10_EXP  (-37)
#define DBL_MIN_10_EXP  (-307)
#define LDBL_MIN_10_EXP (-4931)

#define FLT_MAX_EXP     128
#define DBL_MAX_EXP     1024
#define LDBL_MAX_EXP    16384

#define FLT_MAX_10_EXP  38
#define DBL_MAX_10_EXP  308
#define LDBL_MAX_10_EXP 4932

#define FLT_MAX     3.40282347e+38F
#define DBL_MAX     1.7976931348623157e+308
#define LDBL_MAX    1.18973149535723176502e+4932L

#define FLT_NORM_MAX    3.40282346638528859811704183484516925e+38F
#define DBL_NORM_MAX    ((double)(1.79769313486231570814527423731704357e+308L))
#define LDBL_NORM_MAX   1.18973149535723176502126385303097021e+4932L

#define FLT_EPSILON     1.19209289550781250000000000000000000e-7F
#define DBL_EPSILON     ((double)(2.22044604925031308084726333618164062e-16L))
#define LDBL_EPSILON    1.08420217248550443400745280086994171e-19L

#define FLT_MIN     1.17549435082228750796873653722224568e-38F
#define DBL_MIN     2.22507385850720138309023271733240406e-308L
#define LDBL_MIN    3.36210314311209350626267781732175260e-4932L

#define FLT_TRUE_MIN    1.40129846432481707092372958328991613e-45F
#define DBL_TRUE_MIN    4.94065645841246544176568792868221372e-324L
#define LDBL_TRUE_MIN   3.64519953188247460252840593361941982e-4951L

#endif // __GINKGO_FLOAT_H
