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 {
4848 }
4949 }
5050
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:
5357 bool sopen () const { return (s_impl & (std::int64_t {1 } << 63 )) != 0 ; }
5458 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+
5864 bool isNA () const { return s_impl == IVAL_NA; }
5965
6066 static const std::int64_t IVAL_MAX = 4611686018427387903LL ;
6167 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 ;
6369
6470 private:
6571 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