pub fn pop_scriptnum(&mut self) -> Result<i64, ScriptError> {
        let bytes = try!(self.pop());
        
        if bytes.len() == 0 {
            return Ok(0);
        }
        if bytes.len() > 4 {
            return Err(ScriptError::NumericOverflow);
        }
        
        // grap each bytes with default 0 
        let b1 = *bytes.get(0).unwrap_or(&0) as i64;
        let b2 = *bytes.get(1).unwrap_or(&0) as i64;
        let b3 = *bytes.get(2).unwrap_or(&0) as i64;
        let b4 = *bytes.get(3).unwrap_or(&0) as i64;

        let signed_magnitude  = b1 | (b2 << 8) | (b3 << 16) | (b4 << 24);
        
        let sign_bit_mask = 0x80_i64 << ((bytes.len()-1)*8);
        
        Ok(
            // if the signed-magnitude is negative,  
            // convert to "normal" two-complement
            if (signed_magnitude & sign_bit_mask) > 0 { 
                -( signed_magnitude ^ sign_bit_mask)
            }
            else {
                signed_magnitude
            }    
        )   
    }
/// Pops a value of the stack, interprets its as a scriptnum
/// and returns it as a i64
///
/// The stack contains byte-arrays.
/// Scriptnums are stored as little-endian, sign-and-magnitude
/// which means that the highest bit of the last byte of the stack-item
/// determines the sign.
/// Numbers larger then 4 bytes can be pushed but not popped
/// This gives a range of -0x7fffffff to +0x7fffffff
///
/// Can return a stack-underflow if no items are on the stack
///
Pops a value of the stack, interprets its as a scriptnum
and returns it as a i64

The stack contains byte-arrays.
Scriptnums are stored as little-endian, sign-and-magnitude
which means that the highest bit of the last byte of the stack-item
determines the sign.
Numbers larger then 4 bytes can be pushed but not popped
This gives a range of -0x7fffffff to +0x7fffffff

Can return a stack-underflow if no items are on the stack
Pops a value of the stack interprets its as a scriptnum and returns it as a i64 The stack contains byte - arrays . Scriptnums are stored as little - endian sign - and - magnitude which means that the highest bit of the last byte of the stack - item determines the sign . Numbers larger then 4 bytes can be pushed but not popped This gives a range of - 0x7fffffff to + 0x7fffffff Can return a stack - underflow if no items are on the stack
pub fn pop_scriptnum(&mut self) -> Result<i64, ScriptError> {
        let bytes = try!(self.pop());
        if bytes.len() == 0 {
            return Ok(0);
        }
        if bytes.len() > 4 {
            return Err(ScriptError::NumericOverflow);
        }
        // grap each bytes with default 0 
        let b1 = *bytes.get(0).unwrap_or(&0) as i64;
        let b2 = *bytes.get(1).unwrap_or(&0) as i64;
        let b3 = *bytes.get(2).unwrap_or(&0) as i64;
        let b4 = *bytes.get(3).unwrap_or(&0) as i64;
        let signed_magnitude  = b1 | (b2 << 8) | (b3 << 16) | (b4 << 24);
        let sign_bit_mask = 0x80_i64 << ((bytes.len()-1)*8);
        Ok(
            // if the signed-magnitude is negative,  
            // convert to "normal" two-complement
            if (signed_magnitude & sign_bit_mask) > 0 { 
                -( signed_magnitude ^ sign_bit_mask)
            }
            else {
                signed_magnitude
            }    
        )   
    }
pub fn pop_scriptnum ( & mut self ) -> Result < i64 , ScriptError > { let bytes = try ! ( self pop ( ) ) ; if bytes . len ( ) == 0 { return Ok ( 0 ) ; } if bytes . len ( ) > 4 { return Err ( ScriptError :: NumericOverflow ) ; } // grap each bytes with default 0  let b1 = * bytes . get ( 0 ) . unwrap_or ( & 0 ) as i64 ; let b2 = * bytes . get ( 1 ) . unwrap_or ( & 0 ) as i64 ; let b3 = * bytes . get ( 2 ) . unwrap_or ( & 0 ) as i64 ; let b4 = * bytes . get ( 3 ) . unwrap_or ( & 0 ) as i64 ; let signed_magnitude = b1 | ( b2 << 8 ) | ( b3 << 16 ) | ( b4 << 24 ) ; let sign_bit_mask = 0x80_i64 << ( ( bytes . len ( ) - 1 ) * 8 ) ; Ok ( // if the signed-magnitude is negative,   // convert to "normal" two-complement if ( signed_magnitude & sign_bit_mask ) > 0 { - ( signed_magnitude ^ sign_bit_mask ) } else { signed_magnitude } ) }
Pops a value of the stack, interprets its as a scriptnum
and returns it as a i64
Pops a value of the stack interprets its as a scriptnum and returns it as a i64
&mut self
&mut self