Skip to content

Support signed/unsigned reals, and a compact representation #6

Description

@cjdoris

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? Perhaps true whenever T is a bits type, and false 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 just InfExtended(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 not T 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.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions