Skip to content

Add Base.ispositive, Base.isnegative #843

@sostock

Description

@sostock

Julia 1.13 introduces the ispositive and isnegative functions. We should add methods for quantities.

However, some cases might be controversial:

  • Is -3°C negative? It is equal to 270.15K, which is positive.
  • What about -3dB and -3dBFS? For now, I wouldn’t add ispositive and isnegative methods for them, since they cannot be compared to numbers anyway (-3dB < 0 and -3dBFS < 0 both error).

Another case that I consider slightly less relevant:

  • One can define a unit that is equal to negative meters (@unit negm "negm" NegativeMeter -1m false). Is 1negm (which is equal to -1m) negative or positive? Probably positive, since 1negm < 2negm. However, the fact that 1negm < 2negm but uconvert(m, 1negm) > uconvert(m, 2negm) shows that these units don’t behave nicely anyway. Maybe we could just consider them malformed and don’t pay them any attention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions