Library containing value objects to represent numeric information, parsers to turn user input into such value objects, and formatters to turn them back into user consumable representations.
It is part of the DataValues set of libraries.
On Packagist:

The recommended way to use this library is via Composer.
To add this package as a local, per-project dependency to your project, simply add a
dependency on data-values/number to your project's composer.json file.
Here is a minimal example of a composer.json file that just defines a dependency on
version 1.0 of this package:
{
"require": {
"data-values/number": "1.0.*"
}
}
Get the code of this package, either via git, or some other means. Also get all dependencies. You can find a list of the dependencies in the "require" section of the composer.json file. Then take care of autoloading the classes defined in the src directory.
This library comes with a set up PHPUnit tests that cover all non-trivial code. You can run these tests using the PHPUnit configuration file found in the root directory. The tests can also be run via TravisCI, as a TravisCI configuration file is also provided in the root directory.
DataValues Number has been written by Daniel Kinzler, as [Wikimedia Germany] (https://wikimedia.de) employee for the Wikidata project.
QuantityFormatterconstructor parameters changed in an incompatible way
- Added
QuantityUnitFormatterinterface - Added
BasicQuantityUnitFormatter - Added
QuantityFormatter::OPT_APPLY_UNIToption - Added
QuantityParser::OPT_UNIToption - Added
DecimalParser::applyDecimalExponent - Added
DecimalParser::splitDecimalExponent
QuantityParsernow correctly detects precision for scientific notation- Made constructor parameters optional in
DecimalFormatterandQuantityFormatter - Updated DataValues Interfaces dependency to 0.1.5
- The component can now be installed together with DataValues 1.x
- Unlocalizer interface renamed to NumberUnlocalizer
- Localizer interface renamed to NumberLocalizer
- BasicUnlocalizer interface renamed to BasicNumberUnlocalizer
- BasicLocalizer interface renamed to BasicNumberLocalizer
- Introduced FORMAT_NAME class constants on ValueParsers in order to use them as expectedFormat
- Changed ValueParsers to pass rawValue and expectedFormat when constructing a ParseException
- Unlocalizer: added getNumberRegex() and getUnitRegex()
- Unlocalizer: replaced unlocalize() with unlocalizeNumber()
- Localizer: replaced localize() with localizeNumber()
- Localizer and Unlocalizer: no longer require the target language and options in method calls
- QuantityParser: fixed parsing of internationalized quantity strings
- IntParser got moved to data-values/common
- FloatParser got moved to data-values/common
- DecimalMath::min
- DecimalMath::max
- DecimalMath::shift
- Added option to force displaying the sign in DecimalFormatter
- QuantityParser and DecimalParser now support scientific notation
- DecimalParser now supports localized parsing of values
- DecimalFormatter now supports localization of values
- Floating point errors that occurred when manipulating decimal values have been fixed. (bug 56682)
Initial release with these features:
- DecimalMath
- DecimalValue
- QuantityValue
- DecimalFormatter
- QuantityFormatter
- DecimalParser
- FloatParser
- IntParser
- QuantityParser




