Skip to content

proposal: math: add Float, Integer, Complex, Number interfaces #61914

Open
@djordje200179

Description

@djordje200179

In exp package there was constraints package that contained some interfaces, among which Ordered was added to Go 1.21.

I suggest adding those other number-related interfaces from the packages to the math package. They can be helpful and useful, and I think that math package is the right place for those interfaces (because they group numeric types).

Code that should be added to the math package:

type Complex interface {
	~complex64 | ~complex128
}
type Float interface {
	~float32 | ~float64
}
type Integer interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 |
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}
type Number interface {
	Complex | Float | Integer
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Incoming

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions