Some of those code offerings are a bit confusing so, in addition (and to get a chance to play around a bit too) I thought I'd offer up some other solutions that do not bother checking if this/that is on/off (you can pretty much just rely on AND, OR, or XOR to do that for you:
To make sure snaps are on, you can just do a logand on the 14th bit.
(setvar 'OSMODE (logand (getvar 'OSMODE) -16385))
; -16385 is the 14th bit cleared (aka: (~ 16384))
To toggle snaps on/off, you can just do an XOR on the 14th bit.
(setvar 'OSMODE (boole 6 (getvar 'OSMODE) 16384))
To turn on the osnaps and turn off the nearest snap, you can clear both bits with logand.
(setvar 'OSMODE (logand (getvar 'OSMODE) (+ (1+ (~ 16384)) (~ 512))))
; (1+ (~ 16384)) is -16484
To turn off the osnaps and turn on the nearest snap, you can clear one bit and flip the other with OR.
(setvar 'OSMODE (logior (getvar 'OSMODE) (+ 16384 512)))
To just toggle both bits and hope for the best (use XOR).
(setvar 'OSMODE (boole 6 (getvar 'OSMODE) (+ 16384 512)))
Finaly, to turn snaps on and toggle the nearest bit on/off (use AND & XOR).
(setvar 'OSMODE (logand (boole 6 512 (getvar 'OSMODE)) -16385))