Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docu #14

Merged
merged 1 commit into from
Aug 6, 2024
Merged

Docu #14

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ Phrity\Util\Numerics {
public ceil(float $number, int|null $precision = null): float;
public floor(float $number, int|null $precision = null): float;
public round(float $number, int|null $precision = null): float;
public mceil(float $number, float $multipleOf): float;
public mfloor(float $number, float $multipleOf): float;
public mround(float $number, float $multipleOf): float;
public parse(int|float|string $numeric): float|null;
public format(float $number, int|null $precision = null): string;
public rand(float $min = 0, float[null $max = null, int|null $precision = null): float|null;
Expand Down Expand Up @@ -101,6 +104,42 @@ $numerics->round(1234.5678); // 1234.57
$numerics->round(1234.5678, 0); // 1235.00
```

### Ceil multiple-of method

Round up, according to multiple-of specifier.

```php
$numerics = new Numerics();
$numerics->mceil(123.123, 0.25); // 123.25
$numerics->mceil(123.123, 2.5); // 125
$numerics->mceil(123.123, 25); // 125
$numerics->mceil(123.123, 250); // 250
```

### Floor multiple-of method

Round down, according to multiple-of specifier.

```php
$numerics = new Numerics();
$numerics->mfloor(456.789, 0.25); // 456.75
$numerics->mfloor(456.789, 2.5); // 455
$numerics->mfloor(456.789, 25); // 450
$numerics->mfloor(456.789, 250); // 250
```

### Round multiple-of method

Round, according to multiple-of specifier.

```php
$numerics = new Numerics();
$numerics->mround(456.789, 0.25); // 456.75
$numerics->mround(456.789, 2.5); // 457.5
$numerics->mround(456.789, 25); // 450
$numerics->mround(456.789, 250); // 500
```

### Parse method

Numeric parser. Parses number by evaluating input rather than using locale or making explicit assumtions. Returns `float`, or `null` if provided input can not be parsed.
Expand Down