github.com/tursom/GoCollections@v0.3.10/lang/Complex64.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 Complex64 complex64 14 15 func (i Complex64) AsComplex64() complex64 { 16 return complex64(i) 17 } 18 19 func (i Complex64) String() string { 20 return fmt.Sprint(complex64(i)) 21 } 22 23 func (i Complex64) AsObject() Object { 24 return i 25 } 26 27 func (i Complex64) Equals(e Object) bool { 28 i2, ok := e.(Complex64) 29 if !ok { 30 return false 31 } 32 return i == i2 33 } 34 35 func (i Complex64) ToString() String { 36 return NewString(i.String()) 37 } 38 39 func (i Complex64) HashCode() int32 { 40 return Float32(real(i)).HashCode() ^ Float32(imag(i)).HashCode() 41 }