Support signed/unsigned reals, and a compact representation
cjdoris opened this issue · 0 comments
Two issues, but both require new type parameters to InfExtended
, which could become:
InfExtended{T<:Real, C, S, F}
flag :: F
finitevalue :: T
...
end
Firstly, C
for "compact" is a boolean. When false
then F = InfFlag
and flag
represents whether the value is finite, positive infinity or negative infinity, as is the current implementation (or will be after #4). When true
then F = Nothing
and we use typemax(T)
and typemin(T)
to represent infinity in the finitevalue
. This is "compact" because sizeof(InfExtended{T, true, ...}) == sizeof(T)
, at the expense of losing two finite values from T
.
- What should the default
C
be? Perhapstrue
wheneverT
is a bits type, andfalse
otherwise? - Make this default an overloadable function, so packages can define it for their own types?
- How can we let the user choose? Perhaps
InfExtended(T, :compact=>true)
? Or justInfExtended(T, true)
?
Secondly S
for "signed" is a boolean. When true
then both positive and negative infinity are allowed values. When false
then only positive infinity is allowed. Hence S
should be true whenever T
is a signed type.
- Clearly the default for
S
is whether or notT
is a signed type. - Do we ever let the user choose? I'm thinking no, but we could have a function
issigned(T)
which controls its behaviour.