Documentation
¶
Index ¶
- Variables
- type Rational
- func (r Rational) Float64() float64
- func (r Rational) IsNil() bool
- func (r Rational) MarshalJSON() ([]byte, error)
- func (r Rational) MarshalYAML() (interface{}, error)
- func (r Rational) Percent() float64
- func (r Rational) Reverse() Rational
- func (r Rational) String() string
- func (r Rational) StringAlt() string
- func (r Rational) StringAlt2() string
- func (r *Rational) Unmarshal(fn func(interface{}) error) error
- func (r *Rational) UnmarshalJSON(data []byte) error
- func (r *Rational) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Rational0 represents Nil Rational. Rational0 = Rational{0, 0} // Rational100 represents completed Rational. Rational100 = Rational{100, 100} )
View Source
var ( // ErrWrongPartsNumber indicates parsing error // because of wrong parts number in raw string. ErrWrongPartsNumber error = errors.New("got wrong string parts number") // ErrParseNum indicates parsing numerator error. ErrParseNum error = errors.New("failed parse numerator") // ErrParseDen indicates parsing denumerator error. ErrParseDen error = errors.New("failed parse denumerator") )
Functions ¶
This section is empty.
Types ¶
type Rational ¶
type Rational struct { Num uint64 `json:"num" yaml:"num" bson:"num"` Den uint64 `json:"den" yaml:"den" bson:"den"` }
Rational number numerator/denominator.
func NewRational ¶
NewRational parses raw string and returns Rational.
func (Rational) MarshalJSON ¶
MarshalJSON implements json Marshaler.
func (Rational) MarshalYAML ¶
MarshalYAML implements yaml Marshaler.
func (Rational) StringAlt2 ¶ added in v0.0.2
String returns string representation with sepAlt.
func (*Rational) UnmarshalJSON ¶
UnmarshalJSON implements json Unmarshaler.
func (*Rational) UnmarshalYAML ¶
UnmarshalYAML implements yaml Unmarshaler.
Click to show internal directories.
Click to hide internal directories.