Created
April 14, 2022 07:11
-
-
Save damithadayananda/740a7ee95c8dcde4c7dce5d6704a6396 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"golang.org/x/exp/constraints" | |
) | |
func main() { | |
fmt.Println(GenericMul[float32](2.1,3.2)) | |
} | |
func GenericMul[T constraints.Float](x, y T) T { | |
if x< y{ | |
return x * y | |
} | |
return x/(y) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment