File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -48,18 +48,24 @@ namespace nanotime {
48
48
}
49
49
}
50
50
51
- dtime getStart () const { return dtime (duration (s_impl)); }
52
- dtime getEnd () const { return dtime (duration (e_impl)); }
51
+ dtime getStart () const { return dtime (duration (s ())); }
52
+ dtime getEnd () const { return dtime (duration (e ())); }
53
+
54
+ // below we do some bit gynmastic to use the uppermost bit to store whether the
55
+ // interval is opened or closed; bitfields would give us all that for free,
56
+ // but we can't rely upon them because of Windows:
53
57
bool sopen () const { return (s_impl & (std::int64_t {1 } << 63 )) != 0 ; }
54
58
bool eopen () const { return (e_impl & (std::int64_t {1 } << 63 )) != 0 ; }
55
- std::int64_t s () const { return s_impl & ~(std::int64_t {1 } << 63 ); }
56
- std::int64_t e () const { return e_impl & ~(std::int64_t {1 } << 63 ); }
57
-
59
+ static const std::int64_t bit64_compl = ~(std::int64_t {1 } << 63 );
60
+ static const std::int64_t bit63 = std::int64_t {1 } << 62 ;
61
+ std::int64_t s () const { return s_impl & bit64_compl | ((bit63 & s_impl) << 1 ); }
62
+ std::int64_t e () const { return e_impl & bit64_compl | ((bit63 & e_impl) << 1 ); }
63
+
58
64
bool isNA () const { return s_impl == IVAL_NA; }
59
65
60
66
static const std::int64_t IVAL_MAX = 4611686018427387903LL ;
61
67
static const std::int64_t IVAL_MIN = -4611686018427387903LL ;
62
- static const std::int64_t IVAL_NA = -9223372036854775807LL - 1 ;
68
+ static const std::int64_t IVAL_NA = -9223372036854775807LL ;
63
69
64
70
private:
65
71
std::int64_t s_impl; // start of ival; last bit encodes if boundary is open (1) or closed (0)
You can’t perform that action at this time.
0 commit comments