#ifndef _KJS_SIMPLE_NUMBER_H_
#define _KJS_SIMPLE_NUMBER_H_
#include <limits.h>
#include <math.h>
namespace KJS {
class ValueImp;
class SimpleNumber {
public:
enum { tag = 1, shift = 2, mask = (1 << shift) - 1, sign = 1 << 31, max = (1 << (31 - shift)) - 1, min = -max - 1 };
static inline bool is(const ValueImp *imp) { return ((int)imp & mask) == tag; }
static inline int value(const ValueImp *imp) { return ((int)imp >> shift) | (((int)imp & sign) ? ~max : 0); }
static inline bool fits(int i) { return i <= max && i >= min; }
static inline bool fits(unsigned i) { return i <= (unsigned)max; }
static inline bool fits(long i) { return i <= max && i >= min; }
static inline bool fits(unsigned long i) { return i <= (unsigned)max; }
static inline bool fits(double d) { return d <= max && d >= min && d == (double)(int)d; }
static inline ValueImp *make(int i) { return (ValueImp *)((i << shift) | tag); }
};
}
#endif