---
title: "Decimal – API-Referenz · Quittio"
description: "Helpers for exact decimal arithmetic. Floats are rejected on purpose, see rejectFloat()."
canonical_url: "https://quittio.dev/docs/api/Quittio/Core/Support/Decimal"
locale: de
meta:
  "og:description": "Helpers for exact decimal arithmetic. Floats are rejected on purpose, see rejectFloat()."
  "og:image": "https://quittio.dev/og/quittio-de.jpg"
  "og:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
  "og:image:height": "630"
  "og:image:type": image/jpeg
  "og:image:width": "1200"
  "og:title": "Decimal – API-Referenz · Quittio"
  "twitter:image": "https://quittio.dev/og/quittio-de.jpg"
  "twitter:image:alt": "Quittio: E-Rechnungen für PHP und Laravel. Rechtssicher, validiert, archiviert, mit geprüfter Beispielrechnung."
---

> Index of every page on this site: [llms.txt](https://quittio.dev/llms.txt)

[API reference](https://quittio.dev/docs/api) / [Quittio](https://quittio.dev/docs/api/Quittio) \\ [Core](https://quittio.dev/docs/api/Quittio/Core) \\ [Support](https://quittio.dev/docs/api/Quittio/Core/Support)

# Decimal

final class in quittio/core

`Quittio\Core\Support\Decimal` · [Source](https://github.com/Quittio/quittio/blob/v0.7.1/packages/core/src/Support/Decimal.php#L16)

Helpers for exact decimal arithmetic. Floats are rejected on purpose, see rejectFloat().

## Constants \#

| Constant | Value | Description |
| --- | --- | --- |
| `PLAIN_PATTERN` | `'/^[+-]?(?:\d+(?:\.\d*)?\|\.\d+)$/'` | Plain decimal notation (xs:decimal): optional sign, digits and decimal point. No exponent, so that "1e999999999" cannot expand to a billion digits, and no thousands separators. |

## Methods \#

| Method | Description |
| --- | --- |
| `::format()` | Plain string without exponent, trailing zeros removed down to $minScale decimals. |
| `::isPlain()` | Whether a string is a decimal number in plain notation, see PLAIN\_PATTERN. |
| `::isZero()` | |
| `::of()` | |
| `::ofNullable()` | |
| `::rejectFloat()` | Passes numbers through that are converted later and rejects floats right away. Public methods accept float in their signature only to reject it here: without it, PHP would silently cut 19.99 to 19 in files without strict types (int\|string coercion). |
| `::round()` | Commercial rounding (half up, away from zero), as required by EN 16931. |

### `format()`#

```
public static function format(BigDecimal $value, int<0, max> $minScale = 0): string
```

static

Plain string without exponent, trailing zeros removed down to $minScale decimals.

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `Brick\Math\BigDecimal` | |
| `$minScale` | `int<0, max>` = `0` | |

<dl><dt>Returns</dt>
<dd><code>string</code></dd>
</dl>

### `isPlain()`#

```
public static function isPlain(string $value): bool
```

static

Whether a string is a decimal number in plain notation, see PLAIN\_PATTERN.

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `string` | |

<dl><dt>Returns</dt>
<dd><code>bool</code></dd>
</dl>

### `isZero()`#

```
public static function isZero(BigDecimal $value): bool
```

static

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `Brick\Math\BigDecimal` | |

<dl><dt>Returns</dt>
<dd><code>bool</code></dd>
</dl>

### `of()`#

```
public static function of(BigNumber|int|float|string $value): BigDecimal
```

static

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `Brick\Math\BigNumber\|int\|float\|string` | floats are rejected, see rejectFloat(); strings must use plain decimal notation, see PLAIN\_PATTERN |

<dl><dt>Returns</dt>
<dd><code>Brick\Math\BigDecimal</code></dd>
<dt>Throws</dt>
<dd><code>Brick\Math\Exception\NumberFormatException</code> – for strings in another notation</dd></dl>

### `ofNullable()`#

```
public static function ofNullable(BigNumber|int|float|string|null $value): ?BigDecimal
```

static

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `Brick\Math\BigNumber\|int\|float\|string\|null` | |

<dl><dt>Returns</dt>
<dd><code>?Brick\Math\BigDecimal</code></dd>
</dl>

### `rejectFloat()`#

```
public static function rejectFloat(T|float $value): T
```

static

Passes numbers through that are converted later and rejects floats right away. Public methods accept float in their signature only to reject it here: without it, PHP would silently cut 19.99 to 19 in files without strict types (int|string coercion).

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `Quittio\Core\Support\T\|float` | |

<dl><dt>Returns</dt>
<dd><code>Quittio\Core\Support\T</code></dd>
</dl>

### `round()`#

```
public static function round(BigDecimal $value, int<0, max> $scale): BigDecimal
```

static

Commercial rounding (half up, away from zero), as required by EN 16931.

| Parameter | Type | Description |
| --- | --- | --- |
| `$value` | `Brick\Math\BigDecimal` | |
| `$scale` | `int<0, max>` | |

<dl><dt>Returns</dt>
<dd><code>Brick\Math\BigDecimal</code></dd>
</dl>

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://quittio.dev/#website","@type":"WebSite","description":"E-Rechnungen für PHP und Laravel: ZUGFeRD, XRechnung und Peppol erstellen, prüfen, lesen und archivieren.","inLanguage":"de-DE","name":"Quittio","url":"https://quittio.dev/","publisher":{"@id":"https://quittio.dev/#identity"},"workTranslation":{"@id":"https://quittio.dev/en#website"}},{"@id":"https://quittio.dev/docs/api/Quittio/Core/Support/Decimal#webpage","@type":"WebPage","description":"Helpers for exact decimal arithmetic. Floats are rejected on purpose, see rejectFloat().","name":"Decimal – API-Referenz","url":"https://quittio.dev/docs/api/Quittio/Core/Support/Decimal","isPartOf":{"@id":"https://quittio.dev/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://quittio.dev/docs/api/Quittio/Core/Support/Decimal"]}],"primaryImageOfPage":{"@id":"https://quittio.dev/#logo"}},{"@id":"https://quittio.dev/#identity","@type":"Organization","description":"Open-Source-Bibliothek für E-Rechnungen in PHP und Laravel (ZUGFeRD, XRechnung, Peppol) und Quittio Managed.","email":"kontakt@niklasforst.de","legalName":"Niklas Forst – Softwareentwicklung","name":"Quittio","url":"https://quittio.dev","founder":{"@type":"Person","name":"Niklas Forst","url":"https://quittio.dev/ueber"},"logo":{"@id":"https://quittio.dev/#logo"},"sameAs":["https://github.com/Quittio/quittio","https://packagist.org/packages/quittio/quittio"]},{"@id":"https://quittio.dev/#logo","@type":"ImageObject","caption":"Quittio","contentUrl":"https://quittio.dev/logo.png","inLanguage":"de-DE","url":"https://quittio.dev/logo.png"}]}
```