1#![cfg_attr(not(feature = "std"), no_std)]
6#![deny(missing_docs)]
7#![deny(clippy::suspicious)]
8#![allow(clippy::comparison_chain)]
9#![allow(clippy::collapsible_else_if)]
10#![allow(clippy::collapsible_if)]
11
12#[cfg(not(feature = "std"))]
13extern crate alloc;
14
15mod common;
16mod conv;
17pub mod ctx;
18mod defs;
19mod ext;
20mod mantissa;
21mod num;
22mod ops;
23mod parser;
24mod strop;
25
26#[cfg(feature = "std")]
27mod for_3rd;
28
29#[doc(hidden)]
30pub mod macro_util;
31
32pub use crate::defs::Error;
33pub use crate::defs::Exponent;
34pub use crate::defs::Radix;
35pub use crate::defs::RoundingMode;
36pub use crate::defs::Sign;
37pub use crate::defs::Word;
38pub use crate::ext::BigFloat;
39pub use crate::ext::FromExt;
40pub use crate::ext::INF_NEG;
41pub use crate::ext::INF_POS;
42pub use crate::ext::NAN;
43pub use crate::ops::consts::Consts;
44
45pub use crate::defs::EXPONENT_BIT_SIZE;
46pub use crate::defs::EXPONENT_MAX;
47pub use crate::defs::EXPONENT_MIN;
48pub use crate::defs::WORD_BASE;
49pub use crate::defs::WORD_BIT_SIZE;
50pub use crate::defs::WORD_MAX;
51pub use crate::defs::WORD_SIGNIFICANT_BIT;
52
53#[cfg(test)]
54mod tests {
55
56 #[test]
57 fn test_bigfloat() {
58 use crate::BigFloat;
59 use crate::Consts;
60 use crate::RoundingMode;
61
62 let p = 1024 + 8;
64
65 let rm = RoundingMode::ToEven;
67
68 let mut cc = Consts::new().expect("An error occured when initializing constants");
70
71 let six = BigFloat::from_word(6, 1);
73 let three = BigFloat::from_word(3, p);
74
75 let n = three.sqrt(p, rm);
76 let n = n.reciprocal(p, rm);
77 let n = n.atan(p, rm, &mut cc);
78 let mut pi = six.mul(&n, p, rm);
79
80 pi.set_precision(1024, rm).expect("Precision updated");
82
83 let pi_lib = cc.pi_num(1024, rm).unwrap().into();
85
86 assert_eq!(pi.cmp(&pi_lib), Some(0));
88
89 }
92}