[−][src]Struct script::Num
Script numeric
Numeric opcodes (OP_1ADD, etc) are restricted to operating on 4-byte integers.
The semantics are subtle, though: operands must be in the range [-2^31 +1...2^31 -1],
but results may overflow (and are valid as long as they are not used in a subsequent
numeric operation). CScriptNum enforces those semantics by storing results as
an int64 and allowing out-of-range values to be returned as a vector of bytes but
throwing an exception if arithmetic is done or the result is interpreted as an integer.
Methods
impl Num[src]
impl Numpub fn minimally_encode(data: &[u8], max_size: usize) -> Result<Self, Error>[src]
pub fn minimally_encode(data: &[u8], max_size: usize) -> Result<Self, Error>Reduce the data size to its minimal, and then try to convert it to a num.
pub fn from_slice(
data: &[u8],
require_minimal: bool,
max_size: usize
) -> Result<Self, Error>[src]
pub fn from_slice(
data: &[u8],
require_minimal: bool,
max_size: usize
) -> Result<Self, Error>ⓘImportant traits for Bytespub fn to_bytes(&self) -> Bytes[src]
pub fn to_bytes(&self) -> Bytespub fn is_negative(&self) -> bool[src]
pub fn is_negative(&self) -> boolpub fn is_zero(&self) -> bool[src]
pub fn is_zero(&self) -> boolpub fn abs(&self) -> Num[src]
pub fn abs(&self) -> NumTrait Implementations
impl Debug for Num[src]
impl Debug for Numfn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl PartialEq for Num[src]
impl PartialEq for Numfn eq(&self, other: &Num) -> bool[src]
fn eq(&self, other: &Num) -> boolThis method tests for self and other values to be equal, and is used by ==. Read more
fn ne(&self, other: &Num) -> bool[src]
fn ne(&self, other: &Num) -> boolThis method tests for !=.
impl Eq for Num[src]
impl Eq for Numimpl PartialOrd for Num[src]
impl PartialOrd for Numfn partial_cmp(&self, other: &Num) -> Option<Ordering>[src]
fn partial_cmp(&self, other: &Num) -> Option<Ordering>This method returns an ordering between self and other values if one exists. Read more
fn lt(&self, other: &Num) -> bool[src]
fn lt(&self, other: &Num) -> boolThis method tests less than (for self and other) and is used by the < operator. Read more
fn le(&self, other: &Num) -> bool[src]
fn le(&self, other: &Num) -> boolThis method tests less than or equal to (for self and other) and is used by the <= operator. Read more
fn gt(&self, other: &Num) -> bool[src]
fn gt(&self, other: &Num) -> boolThis method tests greater than (for self and other) and is used by the > operator. Read more
fn ge(&self, other: &Num) -> bool[src]
fn ge(&self, other: &Num) -> boolThis method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
impl Ord for Num[src]
impl Ord for Numfn cmp(&self, other: &Num) -> Ordering[src]
fn cmp(&self, other: &Num) -> OrderingThis method returns an Ordering between self and other. Read more
fn max(self, other: Self) -> Self1.21.0[src]
fn max(self, other: Self) -> SelfCompares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self1.21.0[src]
fn min(self, other: Self) -> SelfCompares and returns the minimum of two values. Read more
impl Clone for Num[src]
impl Clone for Numfn clone(&self) -> Num[src]
fn clone(&self) -> NumReturns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)Performs copy-assignment from source. Read more
impl Copy for Num[src]
impl Copy for Numimpl From<bool> for Num[src]
impl From<bool> for Numimpl From<u8> for Num[src]
impl From<u8> for Numimpl From<u32> for Num[src]
impl From<u32> for Numimpl From<usize> for Num[src]
impl From<usize> for Numimpl From<i32> for Num[src]
impl From<i32> for Numimpl From<i64> for Num[src]
impl From<i64> for Numimpl From<Num> for i64[src]
impl From<Num> for i64impl From<Num> for u32[src]
impl From<Num> for u32impl From<Num> for usize[src]
impl From<Num> for usizeimpl BitAnd for Num[src]
impl BitAnd for Numtype Output = Self
The resulting type after applying the & operator.
fn bitand(self, rhs: Self) -> Self::Output[src]
fn bitand(self, rhs: Self) -> Self::OutputPerforms the & operation.
impl Add for Num[src]
impl Add for Numtype Output = Self
The resulting type after applying the + operator.
fn add(self, rhs: Self) -> Self::Output[src]
fn add(self, rhs: Self) -> Self::OutputPerforms the + operation.
impl Sub for Num[src]
impl Sub for Numtype Output = Self
The resulting type after applying the - operator.
fn sub(self, rhs: Self) -> Self::Output[src]
fn sub(self, rhs: Self) -> Self::OutputPerforms the - operation.
impl Neg for Num[src]
impl Neg for Numtype Output = Self
The resulting type after applying the - operator.
fn neg(self) -> Self::Output[src]
fn neg(self) -> Self::OutputPerforms the unary - operation.
impl Div for Num[src]
impl Div for Numtype Output = Self
The resulting type after applying the / operator.
fn div(self, rhs: Self) -> Self::Output[src]
fn div(self, rhs: Self) -> Self::OutputPerforms the / operation.
impl Rem for Num[src]
impl Rem for NumAuto Trait Implementations
Blanket Implementations
impl<T> ToOwned for T where
T: Clone, [src]
impl<T> ToOwned for T where
T: Clone, type Owned = T
fn to_owned(&self) -> T[src]
fn to_owned(&self) -> TCreates owned data from borrowed data, usually by cloning. Read more
fn clone_into(&self, target: &mut T)[src]
fn clone_into(&self, target: &mut T)🔬 This is a nightly-only experimental API. (toowned_clone_into)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> From for T[src]
impl<T> From for Timpl<T, U> Into for T where
U: From<T>, [src]
impl<T, U> Into for T where
U: From<T>, impl<T, U> TryFrom for T where
T: From<U>, [src]
impl<T, U> TryFrom for T where
T: From<U>, type Error = !
try_from)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>try_from)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized, [src]
impl<T> Borrow for T where
T: ?Sized, ⓘImportant traits for &'a mut Rfn borrow(&self) -> &T[src]
fn borrow(&self) -> &TImmutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>, [src]
impl<T, U> TryInto for T where
U: TryFrom<T>, type Error = <U as TryFrom<T>>::Error
try_from)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>try_from)Performs the conversion.
impl<T> BorrowMut for T where
T: ?Sized, [src]
impl<T> BorrowMut for T where
T: ?Sized, ⓘImportant traits for &'a mut Rfn borrow_mut(&mut self) -> &mut T[src]
fn borrow_mut(&mut self) -> &mut TMutably borrows from an owned value. Read more
impl<T> Any for T where
T: 'static + ?Sized, [src]
impl<T> Any for T where
T: 'static + ?Sized, fn get_type_id(&self) -> TypeId[src]
fn get_type_id(&self) -> TypeId🔬 This is a nightly-only experimental API. (get_type_id)
this method will likely be replaced by an associated static
Gets the TypeId of self. Read more