Find the number which is formed by the last n digits of the string where n = powerOf2
long i , number = 0 ; int len = str . Length ; for ( i = len - powerOf2 ; i < len ; i ++ ) { number += ( long ) ( ( str [ ( int ) i ] - '0' ) * Math . Pow ( 10 , powerOf2 - 1 ) ) ; powerOf2 -- ; }