googology/
lib.rs

1//! # Googology
2//! Googlogy is the [study and nomenclature of large numbers.](https://googology.wikia.org/wiki/Googology)
3//! This crate is focused on the latter component of that description,
4//! and provides utilities for converting numbers of arbitrarily large size
5//! to some natural-language description.
6//! 
7//! Currently, this crate supports two systems for naming large numbers. 
8//! 
9//! The first is the [Conway-Wechsler]((http://www.mrob.com/pub/math/largenum.html#conway-wechsler))
10//! system, which uses names that may be familiar to English speakers, such as
11//! million, billion, and so on... By chaining latin prefixes together (such as in
12//! the number "one millitrillion"), it is possible it is possible to use this
13//! system to generate a name for any number, provided one has enough memory to
14//! store both the digits in the input, as well as the string output.
15//! 
16//! This system supports three different "scale" parameters:
17//! * `Scale::Short` uses a modern English naming convention where each new "illion"
18//! is scaled by powers of 1,000. The value of 10^9 is called `"one billion"`.
19//! * `Scale::LongBritish` uses an older convention used in the UK prior to 1974.
20//! Each new "illion" is scaled by powers of 1,000,000, and powers of 1,000 that
21//! lie in between "illions" are prefixed with "thousand". Thus, the value of 10^9
22//! is called `"one thousand million"`.
23//! * `Scale::LongPeletier` uses a naming convention still in use in many European
24//! languages. Similar to `Scale::LongBritish`, "illions" are scaled by powers of
25//! 1,000,000. However, instead of prefixing the in betweens with "thousand", they
26//! are instead suffixed with "ard" instead of "on". Thus, the value of 10^9 is
27//! called `"one milliard"`. 
28//! 
29//! An alternative system called the Knuth-Yllion system is also provided. Here,
30//! rather than scaling by powers of 1,000 or powers of 1,000,000, the scaling is
31//! instead exponential. A new name is given for each n in 10^(2^n). For example,
32//! 10^2 is one hundred, 10^4 is one myriad, and 10^8 is one myllion. For values
33//! in between, we describe an "yllion" number with those of lesser magnitude. For
34//! example, 10^14 would be called "one hundred myriad myllion".
35//! 
36//! Two functions are provided in each module:
37//! * `full_name` gives a name to any arbitrary number, given a base-10 string
38//! representation of its digits.
39//! * `power_of_ten` gives a name to a power of ten. This can be useful for numbers
40//! that may be so large that storing them in memory would be impossible or
41//! otherwise impractical.
42
43
44mod common;
45pub mod conway_wechsler;
46pub mod knuth_yllion;
47
48#[derive(Debug, Clone, PartialEq, Eq)]
49pub enum ParseError {
50	/// Input was the empty string.
51	Empty,
52	/// Input is too large to be given a name by knuth_yllion.
53	InputTooLarge,
54	/// The parser entered some sort of invalid state.
55	/// If this error is returned, there is a bug in the googology crate.
56	InternalError,
57	/// Input contains some digits other than 0-9.
58	InvalidDigit,
59}