GoCollections/lang/Complex64.go
2022-03-23 10:15:18 +08:00

36 lines
568 B
Go

package lang
import (
"fmt"
)
type Complex64 complex64
func (i Complex64) AsComplex64() complex64 {
return complex64(i)
}
func (i Complex64) String() string {
return fmt.Sprint(complex64(i))
}
func (i Complex64) AsObject() Object {
return i
}
func (i Complex64) Equals(e Object) bool {
i2, ok := e.(Complex64)
if !ok {
return false
}
return i == i2
}
func (i Complex64) ToString() String {
return NewString(i.String())
}
func (i Complex64) HashCode() int32 {
return Float32(real(complex64(i))).HashCode() ^ Float32(imag(complex64(i))).HashCode()
}