## SkyVerge\Math
### A fork of the `brick/math` library to enable usage in distributed WordPress plugins
The library namespace is replaced with `SkyVerge\Math` to avoid version conflicts when installing in a distributed manner (WordPress). Note that this change is only applied to the 0.5 version of the library, in order to support PHP 7.0. Other versions of the library remain unaffected in this fork.
You should be able to use this as a drop-in replacement by simply using the `Skyverge\Math` namespace instead of `Brick\Math`.
<img src="https://raw.githubusercontent.com/brick/brick/master/logo.png" alt="" align="left" height="64">
A library to work with arbitrary precision numbers.
[![Build Status](https://secure.travis-ci.org/brick/math.svg?branch=master)](http://travis-ci.org/brick/math)
[![Coverage Status](https://coveralls.io/repos/brick/math/badge.svg?branch=master)](https://coveralls.io/r/brick/math?branch=master)
[![Latest Stable Version](https://poser.pugx.org/brick/math/v/stable)](https://packagist.org/packages/brick/math)
[![License](https://poser.pugx.org/brick/math/license)](https://packagist.org/packages/brick/math)
For a complete list of classes and methods, check the [API documentation](http://brick.io/math/).
### Installation
This library is installable via [Composer](https://getcomposer.org/).
Just define the following requirement in your `composer.json` file:
```json
{
"require": {
"skyverge/math": "0.5.*"
}
}
```
### Requirements
This library requires PHP 5.6, PHP 7 or [HHVM](http://hhvm.com/).
Although the library can work seamlessly on any PHP installation, it is highly recommended that you install the
[GMP](http://php.net/manual/en/book.gmp.php) or [BCMath](http://php.net/manual/en/book.bc.php) extension
to speed up calculations. The fastest available calculator implementation will be automatically selected at runtime.
### Project status & release process
While this library is still under development, it is well tested and should be stable enough to use in production
environments.
The current releases are numbered `0.x.y`. When a non-breaking change is introduced (adding new methods, optimizing
existing code, etc.), `y` is incremented.
**When a breaking change is introduced, a new `0.x` version cycle is always started.**
It is therefore safe to lock your project to a given release cycle, such as `0.5.*`.
If you need to upgrade to a newer release cycle, check the [release history](https://github.com/brick/math/releases)
for a list of changes introduced by each further `0.x.0` version.
### Package contents
This library provides the following public classes in the [SkyVerge\Math](http://brick.io/math/namespace-Brick.Math.html) namespace:
- [BigNumber](http://brick.io/math/class-Brick.Math.BigNumber.html): base class for `BigInteger`, `BigDecimal` and `BigRational`
- [BigInteger](http://brick.io/math/class-Brick.Math.BigInteger.html): represents an arbitrary-precision integer number.
- [BigDecimal](http://brick.io/math/class-Brick.Math.BigDecimal.html): represents an arbitrary-precision decimal number.
- [BigRational](http://brick.io/math/class-Brick.Math.BigRational.html): represents an arbitrary-precision rational number (fraction).
- [RoundingMode](http://brick.io/math/class-Brick.Math.RoundingMode.html): holds constants for the [rounding modes](http://brick.io/math/class-Brick.Math.RoundingMode.html).
And the following exceptions in the [SkyVerge\Math\Exception](http://brick.io/math/namespace-Brick.Math.Exception.html) namespace:
- [ArithmeticException](http://brick.io/math/class-Brick.Math.Exception.ArithmeticException.html): base class for all exceptions
- [DivisionByZeroException](http://brick.io/math/class-Brick.Math.Exception.DivisionByZeroException.html): thrown when a division by zero occurs
- [NumberFormatException](http://brick.io/math/class-Brick.Math.Exception.NumberFormatException.html): thrown when parsing a number string in an invalid format
- [RoundingNecessaryException](http://brick.io/math/class-Brick.Math.Exception.RoundingNecessaryException.html): thrown when the result of the operation cannot be represented without explicit rounding
### Overview
#### Instantiation
The constructors of the classes are not public, you must use a factory method to obtain an instance.
All classes provide an `of()` factory method that accepts any of the following types:
- `BigNumber` instances
- `int` numbers
- `float` numbers
- `string` representations of integer, decimal and rational numbers
Example:
```php
BigInteger::of(123546);
BigInteger::of('9999999999999999999999999999999999999999999');
BigDecimal::of(1.2);
BigDecimal::of('9.99999999999999999999999999999999999999999999');
BigRational::of('2/3');
BigRational::of('1.1'); // 11/10
```
Note that all `of()` methods accept all of the representations above, *as long as it can be safely converted to
the current type*:
```php
BigInteger::of('1.00'); // 1
BigInteger::of('1.01'); // ArithmeticException
BigDecimal::of('1/8'); // 0.125
BigDecimal::of('1/3'); // ArithmeticException
```
Note about native integers: instantiating from an `int` is safe *as long as you don't exceed the maximum
value for your platform* (`PHP_INT_MAX`), in which case it would be transparently converted to `float` by PHP without
notice, and could result in a loss of information. In doubt, prefer instantiating from a `string`, which supports
an unlimited numbers of digits:
```php
echo BigInteger::of(999999999999999999999); // 1000000000000000000000
echo BigInteger::of('999999999999999999999'); // 999999999999999999999
```
Note about floating-point values: instantiating from a `float` might be unsafe, as floating-point values are
imprecise by design, and could result in a loss of information. Always prefer instantiating from a `string`, which
supports an unlimited number of digits:
```php
echo BigDecimal::of(1.99999999999999999999); // 2
echo BigDecimal::of('1.99999999999999999999'); // 1.99999999999999999999
```
#### Immutability & chaining
The `BigInteger`, `BigDecimal` and `BigRational` classes are immutable: their value never changes,
so that they can be safely passed around. All methods that return a `BigInteger`, `BigDecimal` or `BigRational`
return a new object, leaving the original object unaffected:
```php
$ten = BigInteger::of(10);
echo $ten->plus(5); // 15
echo $ten->multipliedBy(3); // 30
```
The methods can be chained for better readability:
```php
echo BigInteger::of(10)->plus(5)->multipliedBy(3); // 45
```
#### Parameter types
All methods that accept a number: `plus()`, `minus()`, `multipliedBy()`, etc. accept the same types as `of()`.
For example, given the following number:
```php
$integer = BigInteger::of(123);
```
The following lines are equivalent:
```php
$integer->multipliedBy(123);
$integer->multipliedBy('123');
$integer->multipliedBy($integer);
```
Just like `of()`, other types of `BigNumber` are acceptable, as long as they can be safely converted to the current type:
```php
echo BigInteger::of(2)->multipliedBy(BigDecimal::of('2.0')); // 4
echo BigInteger::of(2)->multipliedBy(BigDecimal::of('2.5')); // ArithmeticException
echo BigDecimal::of(2.5)->multipliedBy(BigInteger::of(2)); // 5.0
```
#### Division & rounding
##### BigInteger
By default, dividing a `BigInteger` returns the exact result of the division, or throws an exception if the remainder
of the division is not zero:
```php
echo BigInteger::of(999)->dividedBy(3); // 333
echo BigInteger::of(1000)->dividedBy(3); // RoundingNecessaryException
```
You can pass an optional [rounding mode](http://brick.io/math/class-Brick.Math.RoundingMode.html) to round the result, if necessary:
```php
echo BigInteger::of(1000)->dividedBy(3, RoundingMode::DOWN); // 333
echo BigInteger::of(1000)->dividedBy(3, RoundingMode::UP); // 334
```
If you're into quotients and remainders, there are methods for this, too:
```php
echo BigInteger::of(1000)->quotient(3); // 333
echo BigInteger
没有合适的资源?快使用搜索试试~ 我知道了~
【WordPress插件】2022年最新版完整功能demo+插件v3.20.1.zip
共109个文件
php:77个
js:8个
mo:5个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 190 浏览量
2022-04-22
17:54:20
上传
评论
收藏 382KB ZIP 举报
温馨提示
"【WordPress插件】2022年最新版完整功能demo+插件v3.20.1 WooCommerce Measurement Price Calculator Woocommerce测量价格计算器" ---------- 泰森云每天更新发布最新WordPress主题、HTML主题、WordPress插件、shopify主题、opencart主题、PHP项目源码、安卓项目源码、ios项目源码,更有超10000个资源可供选择,如有需要请站内联系。
资源推荐
资源详情
资源评论
收起资源包目录
【WordPress插件】2022年最新版完整功能demo+插件v3.20.1.zip (109个子文件)
sv-wc-plugin-admin-setup-wizard.min.css 3KB
ajax-loader.gif 885B
bignumber.js 76KB
wc-measurement-price-calculator.js 27KB
wc-measurement-price-calculator.js 26KB
bignumber.min.js 18KB
wc-measurement-price-calculator.min.js 12KB
wc-measurement-price-calculator.min.js 11KB
sv-wp-admin-job-batch-handler.min.js 2KB
sv-wc-plugin-admin-setup-wizard.min.js 994B
installed.json 3KB
LICENSE 1KB
LICENSE 1KB
README.md 9KB
woocommerce-measurement-price-calculator-it_IT.mo 21KB
woocommerce-plugin-framework-et.mo 20KB
woocommerce-measurement-price-calculator-de_DE.mo 9KB
woocommerce-measurement-price-calculator-fr_FR.mo 3KB
woocommerce-measurement-price-calculator-et_EE.mo 529B
apigen.neon 148B
writepanel-product_data-calculator.php 110KB
class-wc-price-calculator-cart.php 51KB
class-sv-wc-plugin.php 36KB
class-wc-price-calculator-product-page.php 35KB
abstract-sv-wc-plugin-admin-setup-wizard.php 34KB
class-wc-price-calculator-settings.php 32KB
class-wc-price-calculator-product.php 30KB
class-wc-price-calculator-inventory.php 28KB
class-sv-wp-background-job-handler.php 27KB
class-sv-wc-helper.php 26KB
class-wc-price-calculator-measurement.php 24KB
class-sv-wc-api-base.php 21KB
BigDecimal.php 20KB
Country_Helper.php 20KB
Lifecycle.php 16KB
writepanels-init.php 15KB
BigInteger.php 15KB
class-sv-wc-framework-bootstrap.php 15KB
ClassLoader.php 14KB
InstalledVersions.php 14KB
class-sv-wc-order-compatibility.php 13KB
class-sv-wc-plugin-compatibility.php 12KB
class-sv-wc-admin-notice-handler.php 12KB
BigRational.php 12KB
class-sv-wc-plugin-dependencies.php 11KB
BigNumber.php 11KB
NativeCalculator.php 10KB
class-sv-wp-admin-message-handler.php 10KB
Calculator.php 10KB
woocommerce-measurement-price-calculator-admin-init.php 9KB
woocommerce-measurement-price-calculator.php 9KB
price-calculator.php 9KB
class-wc-price-calculator-compatibility.php 9KB
class-wc-measurement-price-calculator.php 8KB
Lifecycle.php 8KB
writepanel-product-type-variable.php 7KB
class-sv-wp-job-batch-handler.php 7KB
class-sv-wc-product-compatibility.php 6KB
class-sv-wc-hook-deprecator.php 5KB
writepanel-product_data.php 5KB
Address.php 5KB
quantity-calculator.php 5KB
abstract-sv-wc-data-compatibility.php 5KB
class-wc-price-calculator-shortcode-pricing-table.php 4KB
writepanel-product_data-pricing_table.php 4KB
abstract-sv-wc-api-xml-request.php 4KB
class-sv-wp-async-request.php 4KB
RoundingMode.php 4KB
class-sv-wc-plugin-rest-api.php 4KB
abstract-sv-wc-api-xml-response.php 4KB
Customer_Address.php 4KB
class-sv-wc-datetime.php 3KB
class-wc-price-calculator-product-loop.php 3KB
abstract-sv-wc-api-json-request.php 3KB
strings.php 3KB
abstract-sv-wc-api-json-response.php 3KB
interface-sv-wc-api-request.php 2KB
Shortcodes.php 2KB
autoload_real.php 2KB
interface-sv-wc-api-response.php 2KB
installed.php 1KB
GmpCalculator.php 1KB
class-sv-wc-api-exception.php 1KB
autoload_static.php 1KB
class-sv-wc-plugin-exception.php 1KB
index.php 1KB
BcMathCalculator.php 1KB
phpunit.php 1KB
platform_check.php 925B
ArithmeticException.php 535B
DivisionByZeroException.php 525B
RoundingNecessaryException.php 436B
autoload_psr4.php 288B
autoload_classmap.php 232B
NumberFormatException.php 204B
autoload.php 178B
autoload_namespaces.php 149B
product-data-icon.png 421B
woocommerce-plugin-framework-et.po 73KB
woocommerce-measurement-price-calculator-it_IT.po 54KB
共 109 条
- 1
- 2
资源评论
Lee达森
- 粉丝: 960
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功