Skip to content

Commit aef3e2e

Browse files
committed
---
yaml --- r: 151759 b: refs/heads/try2 c: e30198d h: refs/heads/master i: 151757: 8fc6cde 151755: e23cdab 151751: 5496764 151743: 9162b62 v: v3
1 parent 1c20825 commit aef3e2e

File tree

2 files changed

+35
-1
lines changed

2 files changed

+35
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 91fa8e5f2aaad4620928c8669218971da747e4da
8+
refs/heads/try2: e30198d9d4d4d016949625062bde002bc33aa574
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libnum/lib.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,40 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
//! Simple numerics.
12+
//!
13+
//! This crate contains arbitrary-sized integer, rational, and complex types.
14+
//!
15+
//! ## Example
16+
//!
17+
//! This example uses the BigRational type and [Newton's method][newt] to
18+
//! approximate a square root to arbitrary precision:
19+
//!
20+
//! ```
21+
//! extern crate num;
22+
//!
23+
//! use num::bigint::BigInt;
24+
//! use num::rational::{Ratio, BigRational}:
25+
//!
26+
//! fn approx_sqrt(number: u64, iterations: uint) -> BigRational {
27+
//! let start: Ratio<BigInt> = Ratio::from_integer(FromPrimitive::from_u64(number).unwrap());
28+
//! let mut approx = start.clone();
29+
//!
30+
//! for _ in range(0, iterations) {
31+
//! approx = (approx + (start / approx)) /
32+
//! Ratio::from_integer(FromPrimitive::from_u64(2).unwrap());
33+
//! }
34+
//!
35+
//! approx
36+
//! }
37+
//!
38+
//! fn main() {
39+
//! println!("{}", approx_sqrt(10, 4)); // prints 4057691201/1283082416
40+
//! }
41+
//! ```
42+
//!
43+
//! [newt]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
44+
1145
#![feature(macro_rules)]
1246

1347
#![crate_id = "num#0.11.0-pre"]

0 commit comments

Comments
 (0)