//
//  numberConversion.h
//  GSFontTools
//
//  Created by Alex on 13.06.17.
//
//

#ifndef numberConversion_h
#define numberConversion_h

#include <stdint.h>

typedef int16_t F2DOT14_t;

double GSFixed14ToFloat(F2DOT14_t value);

F2DOT14_t GSFloatToFixed14(double value);

//#define Fixed14ToFloat(a) ((double)(a) / (1 << 14))
//#define FloatToFixed14(a) (roundf((float)(a) * (1 << 14)))

#define fixed1              ((Fixed) 0x00010000L)
#define GSFloatToFixed(a)   ((int)((a) * fixed1))
#define GSFixedToFloat(a)   ((float)(a) / fixed1)

#define GSFixed16ToFloat(a) ((double)(a) / (1 << 16))
#define GSFloatToFixed16(a) (int32_t)(round((double)(a) * (1 << 16)))

#define dmax(x, y) (((x) > (y)) ? (x) : (y))
#define dmin(x, y) (((x) < (y)) ? (x) : (y))

#endif /* numberConversion_h */
