# Quantity & Price Representation

When working with prices, percentages, and quantities in the Flow Retail API, it’s important to understand how numeric values are represented.

## Integers Represent Decimals

All amounts, percentages, and quantities in the API are returned and expected as integers, where the value represents a decimal with two fixed decimal places.

* Example:
  * 100 → 1.00
  * 2500 → 25.00
  * -150 → -1.50

This means you never send or receive floating-point numbers like 1.00 or 25.50 directly in the API. Instead, you work with whole numbers that implicitly include two decimal places.

## Why We Use Integers Instead of Floats

#### We follow this design for consistency and accuracy:

1. **Avoid rounding errors**

   Floating-point math in programming languages can introduce tiny rounding inaccuracies. Integers are exact, which is critical for financial data like sales orders and payments, and for stock and warehouse data.
2. **Consistent representation**

   By fixing the scale (2 decimal places), all amounts are handled uniformly across endpoints and integrations.
3. **Cross-platform compatibility**

   Some languages and databases treat decimal and floating-point values differently. Using integers ensures consistent values across all systems.

## How This Affects Development

#### When integrating:

* **Parsing API data**

  Divide by 100 to get the actual value in your application.

```
const amountCents = 2500; // From API
const amount = amountCents / 100; // 25.00
```

* **Sending data to the API**

  Multiply by 100 before sending.

```
const amount = 25.00; // In your app
const amountCents = Math.round(amount * 100); // 2500 for API

```

* **Percentages**

  Percent values follow the same rule: 250 = 2.50%, 1000 = 10.00%.
* **Quantities**

  Quantities also support decimals via the same fixed scale: 150 = 1.50 units.

## Examples

#### Price Example:

```
{
  "price": 1299,   // = 12.99
  "taxRate": 250   // = 2.50% VAT
}
```

#### Quantity Example:

```
{
  "quantity": 150  // = 1.50 units
}
```

## Summary

* Integers with two implied decimal places for amounts, percentages, and quantities.
* Reason: Accuracy, consistency, and cross-platform safety.
* Conversion rule:
  * API → App: divide by 100
  * App → API: multiply by 100
