From b9420b9cbfa63dda2d9a4ad9f1db3ba0fe2b4449 Mon Sep 17 00:00:00 2001 From: Lokathor Date: Mon, 17 Oct 2022 23:18:32 -0600 Subject: [PATCH] docs. --- src/fixed.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/fixed.rs b/src/fixed.rs index 5446e1e..277854d 100644 --- a/src/fixed.rs +++ b/src/fixed.rs @@ -12,7 +12,19 @@ pub type i16fx8 = Fixed; #[allow(non_camel_case_types)] pub type i32fx8 = Fixed; -// TODO: this derived Debug impl prints the wrong thing, but it's fine for now. +/// A [fixed-point][wp-fp] number. This transparently wraps an integer with a +/// const generic for how many bits are fractional. +/// +/// [wp-fp]: https://en.wikipedia.org/wiki/Fixed-point_arithmetic +/// +/// * The `I` type is intended to be a signed or unsigned integer of a specific +/// size: `i8`, `i16`, `i32`, `u8`, `u16`, or `u32`. This type is *not* +/// supported to work with any other `I` type: semver compatible updates to +/// the crate may change the generic bounds on methods that cause other types +/// of `I` to cease working. +/// * The `B` value is the number of bits that form the fractional part. It +/// should be less than the number of bits in the integer's type, or various +/// methods will likely panic when they shift the inner value by too much. #[derive(Debug, Default, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct Fixed(I);