Powershell, 5959 58 bytes
param($n,$m)$n..$m|%{whilefor($_;$_){$s+=$_-band1;$_=$_-shr1}};$s
Test script:
$f = {
param($n,$m)$n..$m|%{whilefor($_;$_){$s+=$_-band1;$_=$_-shr1}};$s
}
@(
,(4,7,8)
,(10,20,27)
,(100,200,419)
,(1,3,4)
,(1,2,2)
,(1000,2000,5938)
) | % {
$n,$m,$e=$_
$r = &$f $n $m
$c = $r -eq $e
"$c : $n , $m ---> $e = $r"
}
Output:
True : 4 , 7 ---> 8 = 8
True : 10 , 20 ---> 27 = 27
True : 100 , 200 ---> 419 = 419
True : 1 , 3 ---> 4 = 4
True : 1 , 2 ---> 2 = 2
True : 1000 , 2000 ---> 5938 = 5938