File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2121//! Suggested reading order: [Posit] and [Decoded] types, [basics] and [constants](consts),
2222//! [decode] implementation (Posit→Decoded), [encode] implementation (Decoded→Posit),
2323//! [elementary arithmetic](ops).
24+ //!
25+ //! # Testing
26+ //!
27+ //! Extensive tests are included. When possible, we check all inputs exhaustively (e.g.: adding two
28+ //! 8-bit posits, there are only 256² possible inputs). Whenever this is not feasible (e.g: adding
29+ //! two 64-bit posits), we make use of the [`proptest`] crate, which allows us to
30+ //! probabilistically test inputs from a random distribution.
31+ //!
32+ //! Another key ingredient in the testing process is in the [`rational`] submodule. There, we
33+ //! define some tools to convert to and from *arbitrary precision* rational numbers. Since any
34+ //! non-NaR posit is a rational number, we can test any function in this crate involving posits by
35+ //! simply checking that the output matches the output of the equivalent function using
36+ //! infinite-precision rationals. For instance: to test addition of two posits, we simply check
37+ //! that `rational(a) + rational(b) == rational(a + b)`, i.e. adding the posits yields the same
38+ //! result as adding the arbitrary-precision rationals (modulo rounding, of course).
2439
2540/// A *posit* floating point number with `N` bits and `ES` exponent bits, using `Int` as its
2641/// underlying type.
You can’t perform that action at this time.
0 commit comments