Skip to main content

Real

Struct Real 

Source
pub struct Real {
    pub negative: bool,
    pub digits: [u8; 12],
    pub exponent: i32,
}
Expand description

A real number exactly as the calculator stores it: sign, 12 decimal digits with the point after the first, exponent -499..=499.

Fields§

§negative: bool

Negative.

§digits: [u8; 12]

Mantissa digits, most significant first; the first is nonzero unless the number is 0.

§exponent: i32

Decimal exponent.

Implementations§

Source§

impl Real

Source

pub const ZERO: Real

Zero.

Source

pub fn from_body(body: &[u8]) -> Result<Real, DecodeError>

Decode a 16-nibble real body: 3-nibble tens-complement exponent, 12 mantissa digits from the least significant up, sign (0 or 9). An error’s offset is the nibble of body where it is not a real.

Source

pub fn to_body(&self) -> [u8; 16]

The 16-nibble body.

Source

pub fn to_f64(&self) -> f64

The nearest f64 (exact to 12 digits within F64_EXPONENTS).

Source

pub fn to_source(&self) -> String

RPL source that compiles to exactly this real: 5., -1.5E-300, 4.79425538604E-1.

Source

pub fn parse(text: &str) -> Result<Real, Error>

Parse decimal text (0.5, -1.5E-300, 12, .479425538604), rounding to 12 significant digits (half away from zero).

Source

pub fn from_f64(v: f64) -> Result<Real, Error>

The real nearest to v, rounded to 12 digits.

Trait Implementations§

Source§

impl Clone for Real

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Real

Source§

impl Debug for Real

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Real

Source§

fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Real, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Real

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Real

Source§

impl PartialEq for Real

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Real

Source§

fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Real

Auto Trait Implementations§

§

impl Freeze for Real

§

impl RefUnwindSafe for Real

§

impl Send for Real

§

impl Sync for Real

§

impl Unpin for Real

§

impl UnsafeUnpin for Real

§

impl UnwindSafe for Real

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.