Home

Awesome

Mentioned in Awesome Go

gofal

中文文档

Example

1、 Add

	tmp := fractional.Model(7, 12)
	tmp1 := fractional.Model(1, 12)
	fmt.Println(tmp.Add(tmp1))
2/3

2、 Subtraction

	tmp = fractional.Model(1, 4)
	tmp1 = fractional.Model(1, 3)
	fmt.Println(tmp.Sub(tmp1))
-1/12

3、Multiplication

	tmp = fractional.Model(3, 4)
	tmp1 = fractional.Model(2, 3)
	fmt.Println(tmp.Mul(tmp1))
1/2

4、 Division

	tmp = fractional.Model(3, 4)
	tmp1 = fractional.Model(2, 3)
	fmt.Println(tmp.Div(tmp1))
9/8

5、 out put (flat64)

    tmp = fractional.Model(1, 3)
	fmt.Println(tmp.Verdict())
0.3333333333333333

6、Chain expression

	tmp := fractional.Model(1, 3)
	tmp.Add(fractional.Model(1)).Mul(tmp)
	fmt.Println(tmp)
16/9