aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--format.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/format.go b/format.go
index b1a939c..d635be9 100644
--- a/format.go
+++ b/format.go
@@ -1,6 +1,9 @@
package main
-import "fmt"
+import (
+ "fmt"
+ "math"
+)
type S string // string
type I int64 // int
@@ -35,3 +38,15 @@ func (f F) String() string {
func (c C) String() string {
return fmt.Sprint(F(real(c)), "J", F(imag(c)))
}
+
+func IsInt(c complex128) bool {
+ return imag(c) == 0 && math.Trunc(real(c)) == real(c)
+}
+
+func IsFloat(c complex128) bool {
+ return imag(c) == 0 && math.Trunc(real(c)) != real(c)
+}
+
+func IsComplex(c complex128) bool {
+ return imag(c) != 0
+}