11# Documentation
2-
32## Instanciation
4-
53` Number::of(any) ` accepts any numeric value like floats, integers and even strings or other Number instances
64
7- e.g: ` Number::of("1.5") ` , ` Number::of(1/3) ` , ` Number::of(1) ` , ` Number::of(Number::of(12.8)) ` are valid and correctly handled
8-
9- On the other hand, the strings must be sane
5+ e.g: ` Number::of("1.5") ` , ` Number::of(1/3) ` , ` Number::of(1) ` , ` Number::of(Number::of(12.8)) ` are valid and correctly handled
106
7+ On the other hand, the strings must be sane
118e.g ` Number::of('1/3') ` , ` Number::of('1,2') ` , ` Number::of('1.5€') ` will throw an exception
129
1310Basic instances are already built-in:
14-
1511- ` Number::zero() ` alias for Number::of(0)
1612- ` Number::one() ` alias for Number::of(1)
1713- ` Number::ten() ` alias for Number::of(10)
1814- ` Number::hundred() ` alias for Number::of(100)
1915- ` Number::thousand() ` alias for Number::of(1000)
2016
2117## Collections
22-
2318- ` Number::sum(...any) ` return a Number which values to the sum of the values in the collection
2419- ` Number::max(...any) ` return a Number which values to the max value in the collection
2520- ` Number::min(...any) ` return a Number which values to the min value in the collection
@@ -28,9 +23,7 @@ Basic instances are already built-in:
2823Those methods accepts a list of valid values (e.g: ` Number::sum("2", 4, 1/2) ` ) as well as an iterable object (e.g: ` Number::sum(["2", 4, 1/2]) ` )
2924
3025## Methods
31-
3226### Basic maths methods:
33-
3427- ` plus(any) ` returns a Number which values to the sum between the two Numbers
3528- ` minus(any) ` returns a Number which values to the difference between the two Numbers
3629- ` multiply(any) ` returns a Number which values to the multiplication between the two Numbers
@@ -55,12 +48,12 @@ Those methods accepts a list of valid values (e.g: `Number::sum("2", 4, 1/2)`) a
5548- ` isLessOrEqual(any) ` returns the inferiority comparison result
5649
5750### Other useful methods:
58-
51+ - ` wholePart() ` returns a Number which value is the left part of the floating point (e.g 3.52 is 3.0)
52+ - ` decimalPart() ` returns a Number which value is the right part of the floating point (e.g 3.52 is 0.52)
5953- ` isPositive() ` returns whether the Number value is positive or not
6054- ` isNegative() ` returns whether the Number value is negative or not
6155- ` isZero() ` returns whether the Number value is equal to zero
6256- ` isWhole() ` returns whether the Number has a decimal part
63- - ` decimalPlaces() ` returns a count of the decimal part digits
6457- ` apply(callback) ` returns the callback result, useful for custom functions
6558- ` when(bool, callback) ` returns the callback result if the condition is truthy
6659- ` format(locale, decimals, forceDecimals) ` returns the display format of the number in the desired locale (not for database storage!)
@@ -70,8 +63,6 @@ Those methods accepts a list of valid values (e.g: `Number::sum("2", 4, 1/2)`) a
7063- ` get() ` returns the raw internal float value (for debug purposes)
7164- ` value() ` returns the float value, preferred over value(), because the format will be right (no strange values like -0.0)
7265- ` sign() ` returns ` + ` or ` - ` . N.B: Zero will be positive.
73- - ` wholePart() ` returns the left part of the floating point (e.g 3.52 is 3)
74- - ` decimalPart() ` returns the right part of the floating point (e.g 3.52 is 0.52)
7566
7667All accessors can be retrieved as properties like ` ->value ` or ` ->sign ` .
7768
0 commit comments