[−][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 Num
pub 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) -> Bytes
pub fn is_negative(&self) -> bool
[src]
pub fn is_negative(&self) -> bool
pub fn is_zero(&self) -> bool
[src]
pub fn is_zero(&self) -> bool
pub fn abs(&self) -> Num
[src]
pub fn abs(&self) -> Num
Trait Implementations
impl Debug for Num
[src]
[+]
impl Debug for Num
impl PartialEq for Num
[src]
[+]
impl PartialEq for Num
impl Eq for Num
[src]
impl Eq for Num
impl PartialOrd for Num
[src]
[+]
impl PartialOrd for Num
impl Ord for Num
[src]
[+]
impl Ord for Num
impl Clone for Num
[src]
[+]
impl Clone for Num
impl Copy for Num
[src]
impl Copy for Num
impl From<bool> for Num
[src]
[+]
impl From<bool> for Num
impl From<u8> for Num
[src]
[+]
impl From<u8> for Num
impl From<u32> for Num
[src]
[+]
impl From<u32> for Num
impl From<usize> for Num
[src]
[+]
impl From<usize> for Num
impl From<i32> for Num
[src]
[+]
impl From<i32> for Num
impl From<i64> for Num
[src]
[+]
impl From<i64> for Num
impl From<Num> for i64
[src]
[+]
impl From<Num> for i64
impl From<Num> for u32
[src]
[+]
impl From<Num> for u32
impl From<Num> for usize
[src]
[+]
impl From<Num> for usize
impl BitAnd for Num
[src]
[+]
impl BitAnd for Num
impl Add for Num
[src]
[+]
impl Add for Num
impl Sub for Num
[src]
[+]
impl Sub for Num
impl Neg for Num
[src]
[+]
impl Neg for Num
impl Div for Num
[src]
[+]
impl Div for Num
impl Rem for Num
[src]
[+]
impl Rem for Num
Auto 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) -> T
Creates 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 T
impl<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) -> &T
Immutably 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 T
Mutably 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