number

package module
v2.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 15, 2022 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FloatingPrecision uint64 = 10    // Nombre de chiffres après la virgule pour un nombre décimal ou un nombre scientifique
	FixedPrecision           = false // Si vrai le nombre chiffre après la virgule est fixe.
)

Functions

func Eq

func Eq(n1, n2 Number) bool

Eq vérifie n1 = n2.

func Ge

func Ge(n1, n2 Number) bool

Ge vérifie n1 ≥ n2.

func Gt

func Gt(n1, n2 Number) bool

Gt vérifie n1 > n2.

func Le

func Le(n1, n2 Number) bool

Le vérifie n1 ≤ n2.

func Lt

func Lt(n1, n2 Number) bool

Lt vérifie n1 < n2.

func Ne

func Ne(n1, n2 Number) bool

Ne vérifie n1 ≠ n2.

func NumDenom

func NumDenom(n Number) (Number, Number)

NumDenom retourne le numérateur et le dénominateur.

func QuoRem

func QuoRem(n1, n2 Number) (Number, Number)

QuoRem retourne n1/n2 & n1%n2.

Types

type Int

type Int struct {
	// contains filtered or unexported fields
}

Int représente un nombre entier implémentant l’interface Number.

func I

func I(n int64, base ...int) (out Int)

I retourne un entier suivant la valeur de n.

func INan

func INan(sign int, base ...int) (out Int)

INan retourne respectivement NaN, +∞ ou -∞ suivant que sign est 0, 1, ou -1.

func ParseInt

func ParseInt(str string, base ...int) (n Int, ok bool)

ParseInt force la conversion en entier.

func (Int) Abs

func (i Int) Abs() Int

func (Int) Add

func (i1 Int) Add(i2 Int) Int

func (Int) Base

func (a Int) Base() int

func (Int) Bit

func (i Int) Bit(b int) int64

func (Int) Cmp

func (i1 Int) Cmp(i2 Int) int

func (Int) Dec

func (i Int) Dec() Int

func (Int) Div

func (i1 Int) Div(i2 Int) Rat

func (Int) Eq

func (i1 Int) Eq(i2 Int) bool

func (Int) Ge

func (i1 Int) Ge(i2 Int) bool

func (Int) Gt

func (i1 Int) Gt(i2 Int) bool

func (Int) Inc

func (i Int) Inc() Int

func (Int) Is

func (i Int) Is(n int64) bool

func (Int) IsDefined

func (a Int) IsDefined() bool

func (Int) IsEven

func (i Int) IsEven() bool

func (Int) IsInf

func (a Int) IsInf() bool

func (Int) IsInfinite

func (a Int) IsInfinite() bool

func (Int) IsNan

func (a Int) IsNan() bool

func (Int) IsNeg

func (a Int) IsNeg() bool

func (Int) IsNinf

func (a Int) IsNinf() bool

func (Int) IsOdd

func (i Int) IsOdd() bool

func (Int) IsPos

func (a Int) IsPos() bool

func (Int) IsZero

func (a Int) IsZero() bool

func (Int) Le

func (i1 Int) Le(i2 Int) bool

func (Int) Len

func (i Int) Len() int

func (Int) Lsh

func (i1 Int) Lsh(i2 Int) Int

func (Int) Lt

func (i1 Int) Lt(i2 Int) bool

func (Int) Mul

func (i1 Int) Mul(i2 Int) Int

func (Int) Ne

func (i1 Int) Ne(i2 Int) bool

func (Int) Neg

func (i Int) Neg() Int

func (Int) Pow

func (i1 Int) Pow(i2 Int) Int

func (Int) Quo

func (i1 Int) Quo(i2 Int) Int

func (Int) QuoRem

func (i1 Int) QuoRem(i2 Int) (q, r Int)

func (Int) Rem

func (i1 Int) Rem(i2 Int) Int

func (Int) Rsh

func (i1 Int) Rsh(i2 Int) Int

func (Int) Sign

func (a Int) Sign() int

func (Int) Sqrt

func (i Int) Sqrt() Int

func (Int) Sqrtn

func (i1 Int) Sqrtn(i2 Int) Int

func (Int) String

func (i Int) String() string

func (Int) Sub

func (i1 Int) Sub(i2 Int) Int

func (Int) ToInt

func (i Int) ToInt(base ...int) (out Int)

func (Int) ToRat

func (i Int) ToRat(base ...int) (out Rat)

func (Int) Type

func (i Int) Type() NumberType

type Number

type Number interface {
	Type() NumberType // Type du nombre
	Sign() int        // Son signe (1 si positif, -1 si négatif, 0 si 0 ou NaN)
	Base() int        // Sa base (comprise entre 2 et 36)
	IsNeg() bool      // Vrai si c’est un nombre négatif
	IsPos() bool      // Vrai si c’est un nombre positif
	IsZero() bool     // Vrai si c’est le nombre 0
	IsDefined() bool  // Vrai si c’est un nombre non fini
	IsNan() bool      // Vrai si c’est NaN
	IsInfinite() bool // Vrai si c’est -∞ ou +∞
	IsInf() bool      // Vrai si c’est +∞
	IsNinf() bool     // Vrai si c’est -∞
	Is(int64) bool    // Vrai si le nombre égale n
	String() string   // Représentation graphique du nombre
	ToInt(...int) Int // Convertit le nombre en type entier
	ToRat(...int) Rat // Convertit le nombre en type non entier
}

Number est une interface représentant un nombre.

func Abs

func Abs(n Number) Number

Abs retourne |n|.

func Add

func Add(n1, n2 Number) Number

Add retourne n1+n2.

func Cmp

func Cmp(n1, n2 Number) Number

Cmp compare n1 et n2.

func Denom

func Denom(n Number) Number

Denom retourne le dénominateur.

func Div

func Div(n1, n2 Number) Number

Div retourne n1÷n2.

func Fact

func Fact(n Number) Number

Fact retourne n!.

func Inf

func Inf() Number

Inf retourne +∞.

func Inv

func Inv(n Number) Number

Inv retourne 1/n.

func Lsh

func Lsh(n1, n2 Number) Number

Lsh retourne n1 << n2.

func Mul

func Mul(n1, n2 Number) Number

Mul retourne n1×n2.

func Nan

func Nan() Number

Nan retourne un nombre indéfini.

func Neg

func Neg(n Number) Number

Neg retourne -n.

func Ninf

func Ninf() Number

Ninf retourne -∞.

func Num

func Num(n Number) Number

Num retourne le numérateur.

func Parse

func Parse(str string) (n Number, ok bool)

Parse convertit la chaîne fournie en nombre. Si la conversion réusiit ok est vrai.

func Pow

func Pow(n, p Number) Number

Pow retourne n^p.

func Quo

func Quo(n1, n2 Number) Number

Quo retourne la division entière de n1÷n2.

func Rem

func Rem(n1, n2 Number) Number

Rem retourne n1%n2.

func Rsh

func Rsh(n1, n2 Number) Number

Rsh retourne n1 >> n2.

func Sqrt

func Sqrt(n Number) Number

Sqrt retourne √n.

func Sqrtn

func Sqrtn(n, s Number) Number

Sqrtn retourne n^(1/s).

func Sub

func Sub(n1, n2 Number) Number

Sub retourne n1-n2.

func ToBase

func ToBase(n Number, b int) Number

ToBase convertit n selon la base donnée.

func ToDec

func ToDec(n Number, base ...int) Number

ToDec convertit n en nombre décimal. Si une base est donnée la base est également convertie.

func ToFrac

func ToFrac(n Number, base ...int) Number

ToFrac convertit n en fraction. Si une base est donnée la base est également convertie.

func ToInt

func ToInt(n Number, base ...int) Number

ToInt convertit n en fraction. Si une base est donnée la base est également convertie.

func ToSci

func ToSci(n Number, base ...int) Number

ToSci convertit n en nombre scientifique. Si une base est donnée la base est également convertie.

type NumberType

type NumberType int

Nu.NumberType représente le type d’un nombre.

const (
	INTEGER NumberType = iota
	DECIMAL
	FRACTION
	SCIENTIFIC
)

type Rat

type Rat struct {
	// contains filtered or unexported fields
}

Rat représente un nombre non entier : - Soit une fraction, sous la forme n/d - Soit un décimal, sous la forme iiiii.dddddd - Soit un nombre scientifique, sous la forme 1.dddddEeee (ou 0.E-0, par exemple)

func D

func D(n, d int64, base ...int) Rat

func DI

func DI(n int64, base ...int) Rat

func DNan

func DNan(sign int, base ...int) Rat

func F

func F(n, d int64, base ...int) Rat

func FI

func FI(n int64, base ...int) Rat

func FNan

func FNan(sign int, base ...int) Rat

func ParseDec

func ParseDec(str string, base ...int) (n Rat, ok bool)

ParseDec force la conversion en nombre décimal.

func ParseFrac

func ParseFrac(str string, base ...int) (n Rat, ok bool)

ParseFrac force la conversion en fraction.

func ParseRat

func ParseRat(str string, base ...int) (n Rat, ok bool)

ParseRat force la conversionb en nombre rationnel.

func ParseSci

func ParseSci(str string, base ...int) (n Rat, ok bool)

ParseSci force la conversion en nombre scientifique.

func S

func S(n, d int64, base ...int) Rat

func SI

func SI(n int64, base ...int) Rat

func SNan

func SNan(sign int, base ...int) Rat

func (Rat) Abs

func (r Rat) Abs() (out Rat)

func (Rat) Add

func (r1 Rat) Add(r2 Rat) Rat

func (Rat) Base

func (a Rat) Base() int

func (Rat) Cmp

func (r1 Rat) Cmp(r2 Rat) int

func (Rat) Dec

func (r Rat) Dec() Rat

func (Rat) Denom

func (r Rat) Denom() Int

func (Rat) Div

func (r1 Rat) Div(r2 Rat) Rat

func (Rat) Eq

func (r1 Rat) Eq(r2 Rat) bool

func (Rat) Ge

func (r1 Rat) Ge(r2 Rat) bool

func (Rat) Gt

func (r1 Rat) Gt(r2 Rat) bool

func (Rat) Inc

func (r Rat) Inc() Rat

func (Rat) Inv

func (r Rat) Inv() Rat

func (Rat) Is

func (r Rat) Is(n int64) bool

func (Rat) IsDefined

func (a Rat) IsDefined() bool

func (Rat) IsInf

func (a Rat) IsInf() bool

func (Rat) IsInfinite

func (a Rat) IsInfinite() bool

func (Rat) IsInt

func (r Rat) IsInt() bool

func (Rat) IsNan

func (a Rat) IsNan() bool

func (Rat) IsNeg

func (a Rat) IsNeg() bool

func (Rat) IsNinf

func (a Rat) IsNinf() bool

func (Rat) IsPos

func (a Rat) IsPos() bool

func (Rat) IsZero

func (a Rat) IsZero() bool

func (Rat) Le

func (r1 Rat) Le(r2 Rat) bool

func (Rat) Lt

func (r1 Rat) Lt(r2 Rat) bool

func (Rat) Mul

func (r1 Rat) Mul(r2 Rat) Rat

func (Rat) Ne

func (r1 Rat) Ne(r2 Rat) bool

func (Rat) Neg

func (r Rat) Neg() (out Rat)

func (Rat) Num

func (r Rat) Num() Int

func (Rat) NumDenom

func (r Rat) NumDenom() (n, d Int)

func (Rat) Pow

func (r1 Rat) Pow(r2 Rat) Rat

func (Rat) Quo

func (r1 Rat) Quo(r2 Rat) Int

func (Rat) QuoRem

func (r1 Rat) QuoRem(r2 Rat) (q Int, r Rat)

func (Rat) Rem

func (r1 Rat) Rem(r2 Rat) Rat

func (Rat) Sign

func (a Rat) Sign() int

func (Rat) Sqrt

func (r Rat) Sqrt() Rat

func (Rat) Sqrtn

func (r Rat) Sqrtn(s Int) Rat

func (Rat) String

func (r Rat) String() string

func (Rat) Sub

func (r1 Rat) Sub(r2 Rat) Rat

func (Rat) ToDec

func (r Rat) ToDec(base ...int) Rat

func (Rat) ToFrac

func (r Rat) ToFrac(base ...int) Rat

func (Rat) ToInt

func (r Rat) ToInt(base ...int) (out Int)

func (Rat) ToRat

func (r Rat) ToRat(base ...int) (out Rat)

func (Rat) ToSci

func (r Rat) ToSci(base ...int) Rat

func (Rat) Type

func (r Rat) Type() NumberType

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL