docs.rs failed to build num-0.1.3
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
num-0.4.0
Simple numerics.
This crate contains arbitrary-sized integer, rational, and complex types.
Example
This example uses the BigRational type and Newton's method to approximate a square root to arbitrary precision:
extern crate num;
use num::bigint::BigInt;
use num::rational::{Ratio, BigRational};
fn approx_sqrt(number: u64, iterations: uint) -> BigRational {
let start: Ratio<BigInt> = Ratio::from_integer(FromPrimitive::from_u64(number).unwrap());
let mut approx = start.clone();
for _ in range(0, iterations) {
approx = (&approx + (&start / &approx)) /
Ratio::from_integer(FromPrimitive::from_u64(2).unwrap());
}
approx
}
fn main() {
println!("{}", approx_sqrt(10, 4)); // prints 4057691201/1283082416
}