aboutsummaryrefslogtreecommitdiff
path: root/format.go
diff options
context:
space:
mode:
Diffstat (limited to 'format.go')
-rw-r--r--format.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/format.go b/format.go
new file mode 100644
index 0000000..5a554eb
--- /dev/null
+++ b/format.go
@@ -0,0 +1,34 @@
+package main
+
+import "fmt"
+
+type S string
+type I int64
+type F float64
+type C complex128
+
+func (s S) String() string {
+ return string(s)
+}
+
+func (i I) String() string {
+ pre := ""
+ if i < 0 {
+ pre = "¯"
+ i = -i
+ }
+ return fmt.Sprint(pre, int64(i))
+}
+
+func (f F) String() string {
+ pre := ""
+ if f < 0 {
+ pre = "¯"
+ f = -f
+ }
+ return fmt.Sprint(pre, int64(f))
+}
+
+func (c C) String() string {
+ return fmt.Sprint(F(real(c)), "J", F(imag(c)))
+}