Documentation ¶
Index ¶
- Constants
- Variables
- func AnyToTen(num string, n int) int
- func GreatestCommonDivisor(x, y int64) int64
- func LeastCommonMultiple(x, y int64) int64
- func TenToAny(num, n int) string
- func TenToAnyWithMapping(num, n int, mapping map[int]string) string
- type Fraction
- func (f Fraction) Add(fra Fraction) Fraction
- func (f Fraction) Div(fra Fraction) Fraction
- func (f Fraction) Float64() float64
- func (f Fraction) IsZero() bool
- func (f Fraction) Mul(fra Fraction) Fraction
- func (f Fraction) MulInt64(n int64) Fraction
- func (f Fraction) Reverse() Fraction
- func (f Fraction) String() string
- func (f Fraction) Sub(fra Fraction) Fraction
- func (f Fraction) ToFakeFraction(multiple int64) Fraction
- func (f Fraction) ToRealFraction() Fraction
Constants ¶
View Source
const DIV_SYMBOL = "/"
Variables ¶
View Source
var One = Fraction{ // contains filtered or unexported fields }
View Source
var (
ZERO_DENOMINATOR = errors.New("Denominator is 0 ! ")
)
View Source
var Zero = Fraction{ // contains filtered or unexported fields }
Functions ¶
func GreatestCommonDivisor ¶
GreatestCommonDivisor 最大公约数:(辗转相除法)
func LeastCommonMultiple ¶
LeastCommonMultiple 最小公倍数:((x*y)/最大公约数)
Types ¶
type Fraction ¶
type Fraction struct {
// contains filtered or unexported fields
}
Fraction 分数
func FloatToFraction ¶
func NewFromFloatByDecimal ¶
NewFromFloatByDecimal 使用decimal 计算,结果可能不完全正确
func (Fraction) ToFakeFraction ¶
ToFakeFraction 真分数扩大
Click to show internal directories.
Click to hide internal directories.