2022-11-25 18:19:33 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2022 tursom. All rights reserved.
|
|
|
|
* Use of this source code is governed by a GPL-3
|
|
|
|
* license that can be found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
2022-03-23 10:15:18 +08:00
|
|
|
package lang
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Complex128 complex128
|
|
|
|
|
|
|
|
func (i Complex128) AsComplex128() complex128 {
|
|
|
|
return complex128(i)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i Complex128) String() string {
|
|
|
|
return fmt.Sprint(complex64(i))
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i Complex128) AsObject() Object {
|
|
|
|
return i
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i Complex128) Equals(e Object) bool {
|
|
|
|
i2, ok := e.(Complex128)
|
|
|
|
if !ok {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
return i == i2
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i Complex128) ToString() String {
|
|
|
|
return NewString(i.String())
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i Complex128) HashCode() int32 {
|
|
|
|
return Float64(real(complex64(i))).HashCode() ^ Float64(imag(complex64(i))).HashCode()
|
|
|
|
}
|