---
name: "std::ratio"
section: "3cxx"
platform: "linux"
package: "libstdc++-12-doc"
version: "12.4.0-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/std::ratio/3cxx"
---

# std::ratio(3cxx)

Provides compile-time rational arithmetic.

## NAME

std::ratio\< \_Num, \_Den \> - Provides compile-time rational arithmetic.

## SYNOPSIS

`#include <ratio>`

### Public Types

**typedef** **ratio**\< num, den \> **type**\

### Static Public Attributes

**static** constexpr **intmax\_t** **den**\
 **static** constexpr **intmax\_t** **num**\

## Detailed Description

### template\<intmax\_t \_Num, intmax\_t \_Den = 1\>

struct std::ratio\< \_Num, \_Den \>"Provides compile-time rational arithmetic.

This class template represents any finite rational number with a numerator and denominator representable by compile-time constants of type intmax\_t. The ratio is simplified when instantiated.

For example:

```
std::ratio<7,-21>::num == -1;
std::ratio<7,-21>::den == 3;
```

## Author

Generated automatically by Doxygen for libstdc++ from the source code.
