github.com/tursom/GoCollections@v0.3.10/lang/Complex128.go (about) 1 /* 2 * Copyright (c) 2022 tursom. All rights reserved. 3 * Use of this source code is governed by a GPL-3 4 * license that can be found in the LICENSE file. 5 */ 6 7 package lang 8 9 import ( 10 "fmt" 11 ) 12 13 type Complex128 complex128 14 15 func (i Complex128) AsComplex128() complex128 { 16 return complex128(i) 17 } 18 19 func (i Complex128) String() string { 20 return fmt.Sprint(complex64(i)) 21 } 22 23 func (i Complex128) AsObject() Object { 24 return i 25 } 26 27 func (i Complex128) Equals(e Object) bool { 28 i2, ok := e.(Complex128) 29 if !ok { 30 return false 31 } 32 return i == i2 33 } 34 35 func (i Complex128) ToString() String { 36 return NewString(i.String()) 37 } 38 39 func (i Complex128) HashCode() int32 { 40 return HashFloat64(real(i)) ^ HashFloat64(imag(i)) 41 }