I've been toying around with implementing a fixed-point type in Julia. This has been mentioned before (http://bit.ly/1DlF2S0) I guess that it is on one or more person's to-do list; does anyone have a fixed-point type they can share?
I made a toy type at this gist: https://gist.github.com/christianpeel/4f630b98fe133b6df690 This type sets the number of fractional bits globally and always uses Int64 for the underlying data. I haven't found a clean way to set the type of the underlying data to an aribitrary integer type (see the second file in the gist for one really ugly workaround). One thing that I kept wanting to do was to somehow pass the type for the underlying in, but the following code isn't allowed. Is there anyway to pass a datatype into a constructor? immutable FixedP{T<:Integer} <: Real num::T FixedP(num::FloatingPoint,T::DataType) = new(convert(T,num*2.0^FPEXP)); end -- chris.p...@ieee.org