Crate rugflo [] [src]

Multiple-precision floating-point numbers

The rugflo crate provides multiple-precision floating-point numbers using the GNU MPFR Library, a library for multiple-precision floating-point computations. It can be helpful to refer to the documentation at the MPFR page.

This crate is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This crate is one of a group of four crates:

  • rugint for arbitrary-precision integers,
  • rugrat for arbitrary-precision rational numbers,
  • rugflo for multiple-precision floating-point numbers, and
  • rugcom for multiple-precision complex numbers.

Basic use

The crate provides the Float type, which holds a multiple-precision floating-point number.

Examples

extern crate rugint;
extern crate rugflo;
use rugint::Assign;
use rugflo::Float;

fn main() {
    // Create a floating-point number with 53 bits of precision.
    // (An `f64` has 53 bits of precision too.)
    let flo53 = Float::from((0xff00ff, 53));
    assert!(flo53.to_f64() == 0xff00ff as f64);
    // Create a floating-point number with only 16 bits of precision.
    let flo16 = Float::from((0xff00ff, 16));
    // Now the number is rounded.
    assert!(flo16.to_f64() == 0xff0100 as f64);
}

Structs

Float

A multi-precision floating-point number. The precision has to be set during construction.

Enums

Constant

The available floating-point constants.

Round

The rounding methods for floating-point values.

Special

Special floating-point values.

Traits

AddRound

Provides addition with a specified rounding method.

AssignRound

Assigns to a number from another value, applying the specified rounding method.

DivRound

Provides division with a specified rounding method.

FromRound

Construct Self via a conversion with a specified precision, applying the specified rounding method.

MulRound

Provides multiplication with a specified rounding method.

PowRound

Provides the power operation inside self with a specified rounding method.

ShlRound

Provides the left shift operation with a specified rounding method.

ShrRound

Provides the right shift operation with a specified rounding method.

SubRound

Provides subtraction with a specified rounding method.

Functions

exp_max

Returns the maximum value for the exponent.

exp_min

Returns the minimum value for the exponent.

prec_max

Returns the maximum value for the precision.

prec_min

Returns the minimum value for the precision.

Type Definitions

Exp

The type for the exponent of a Float value.

Prec

The type for the precision of a Float value.