mirror of
https://github.com/italicsjenga/agb.git
synced 2024-12-24 00:31:34 +11:00
add an example to the new number function
This commit is contained in:
parent
7ad160e30f
commit
ff5a1fbbba
|
@ -301,6 +301,16 @@ impl<I: FixedWidthUnsignedInteger, const N: usize> Num<I, N> {
|
||||||
|
|
||||||
/// Attempts to perform the conversion between two integer types and between
|
/// Attempts to perform the conversion between two integer types and between
|
||||||
/// two different fractional precisions
|
/// two different fractional precisions
|
||||||
|
/// ```
|
||||||
|
/// # use agb_fixnum::*;
|
||||||
|
/// let a: Num<i32, 8> = 1.into();
|
||||||
|
/// let b: Option<Num<u8, 4>> = a.try_change_base();
|
||||||
|
/// assert_eq!(b, Some(1.into()));
|
||||||
|
///
|
||||||
|
/// let a: Num<i32, 8> = 18.into();
|
||||||
|
/// let b: Option<Num<u8, 4>> = a.try_change_base();
|
||||||
|
/// assert_eq!(b, None);
|
||||||
|
/// ```
|
||||||
pub fn try_change_base<J: FixedWidthUnsignedInteger + TryFrom<I>, const M: usize>(
|
pub fn try_change_base<J: FixedWidthUnsignedInteger + TryFrom<I>, const M: usize>(
|
||||||
self,
|
self,
|
||||||
) -> Option<Num<J, M>> {
|
) -> Option<Num<J, M>> {
|
||||||
|
|
Loading…
Reference in a new issue