You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Turn Fixed into a general FixedPoint implementation.
This expands the implementation in Fixed to handle more cases and be
generally more useful. In the future `UFixed` should be merged in and
the special behaviour required by ColorTypes implemented as a new type,
based on this implementation.
Copy file name to clipboardExpand all lines: src/fixed.jl
+72-12Lines changed: 72 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,19 @@
1
-
# 32-bit fixed point; parameter `f` is the number of fraction bits
2
-
immutable Fixed{T <:Signed,f} <:FixedPoint{T, f}
1
+
###
2
+
# Fixed implements a general purpose FixedPoint number.
3
+
# The underlying storage type is given by the parameter `T`,
4
+
# and the number of fractional bits is given by `f`
5
+
# The dot is just before the fractional part so in order to represent one,
6
+
# `f` needs to be atleast smaller by 1 in the unsigned case and smaller by two
7
+
# in the signed case, then the number of bits in `T`.
8
+
#
9
+
# In a further iteration of the design `Fixed` should be renamed to `FixedPoint` and the aliase `typealias Fixed{T <: Signed, f} FixedPoint{T, f}` and `typealias UFixed{T <: Unsigned, f} FixedPoint{T, f}` introduced.
10
+
###
11
+
immutable Fixed{T,f} <:FixedPoint{T, f}
3
12
i::T
4
13
5
14
# constructor for manipulating the representation;
0 commit comments