#if !defined  HAVE_EVENODD_H__
#define       HAVE_EVENODD_H__


#include "fxttypes.h"


static inline bool is_even(ulong x)  { return (0==(x&1)); }
static inline bool is_odd(ulong x)  { return (0!=(x&1)); }

// next or previous even or odd value:
static inline ulong next_even(ulong x)  { return (x|1)+1; }
static inline ulong prev_even(ulong x)  { return (x-1)&~1; }
static inline ulong next_odd(ulong x)  { return (x+1)|1; }
static inline ulong prev_odd(ulong x)  { return (x&~1)-1; }
//static inline ulong next_even(ulong x)  { return x+2-(x&1); }
//static inline ulong prev_even(ulong x)  { return x-2+(x&1); }
//static inline ulong next_odd(ulong x)  { return x+1+(x&1); }
//static inline ulong prev_odd(ulong x)  { return x-1-(x&1); }


// same or next, and same or previous even or odd value:
static inline ulong next0_even(ulong x)  { return (x+1)&~1; }
static inline ulong prev0_even(ulong x)  { return x&~1; }
static inline ulong next0_odd(ulong x)  { return x|1; }
static inline ulong prev0_odd(ulong x)  { return (x-1)|1; }
//static inline ulong next0_even(ulong x)  { return x+(x&1); }
//static inline ulong prev0_even(ulong x)  { return x-(x&1); }
//static inline ulong next0_odd(ulong x)  { return x+1-(x&1); }
//static inline ulong prev0_odd(ulong x)  { return x-1+(x&1); }


#endif  // !defined HAVE_EVENODD_H__
