aboutsummaryrefslogtreecommitdiff
path: root/format.go
blob: 5a554ebd65a474bdc761bfdca037f93c7d53cfb3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
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)))
}