Edge case when both the integers lie in the same segment of continuous 1 s
if ( ( int ) ( ( $ l / $ mul ) * $ mul ) == ( int ) ( ( $ r / $ mul ) * $ mul ) ) { if ( ( ( $ l & ( 1 << $ i ) ) != 0 ) && ( $ r - $ l + 1 ) % 2 == 1 ) $ ans += $ mul ; $ mul *= 2 ; continue ; }