Skip to content

Commit

Permalink
Merge pull request #14 from sirn-se/v2.4
Browse files Browse the repository at this point in the history
Docu
  • Loading branch information
sirn-se authored Aug 6, 2024
2 parents 8a6ad05 + 51a85af commit 97b5597
Showing 1 changed file with 39 additions and 0 deletions.
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

0 comments on commit 97b5597

Please sign in to comment.