---
name: "pmnumberstr"
section: "3"
platform: "linux"
package: "libpcp3-dev"
version: "4.3.2+really4.3.1-0.1"
release: "Debian 10 (Buster)"
platforms: ["linux"]
url: "https://new.carta.tech/pmNumberStr"
---

# pmnumberstr(3)

fixed width output format for numbers

Part of [pmNumberStr(3)](/pmNumberStr/3.md).

## NAME

**pmNumberStr**, **pmNumberStr\_r** - fixed width output format for numbers

## C SYNOPSIS

**#include \<pcp/pmapi.h\>**

**const char \*pmNumberStr(double** *value***);**\
 **char \*pmNumberStr\_r(double** *value***, char \****buf***, int** *buflen***);**

**cc ... -lpcp**

## DESCRIPTION

**pmNumberStr** returns the address of a 8-byte buffer that holds a null-byte terminated representation of *value* suitable for output with fixed width fields. The **pmNumberStr\_r** function does the same, but stores the result in a user-supplied buffer *buf* of length *buflen*, which should have room for at least 8 bytes.

The value is scaled using multipliers in powers of \`\`one thousand'' (the decimal \`\`kilo'') and has a bias that provides greater precision for positive numbers as opposed to negative numbers.

The format depends on the sign and magnitude of *value* as follows (d represents a decimal digit):

| | |
| --- | --- |
| *value* range | format |
| ` > 999995000000000` | **inf?** |
| `999995000000000 - 999995000000` | ddd.dd**T** |
| ` 999995000000 - 999995000` | ddd.dd**G** |
| ` 999995000 - 999995` | ddd.dd**M** |
| ` 999995 - 999.995` | ddd.dd**K** |
| ` 999.995 - 0.005` | ddd.dd |
| ` 0.005 - -0.005` | **0.00** |
| ` -0.005 - -99.95` | -dd.dd |
| ` -99.995 - -99995` | -dd.dd**K** |
| ` -99995 - -99995000` | -dd.dd**M** |
| ` -99995000 - -99995000000` | -dd.dd**G** |
| ` -99995000000 - -99995000000000` | -dd.dd**T** |
| ` < -99995000000000` | **-inf?** |

At the boundary points of the ranges, the chosen format will retain the maximum number of significant digits.

## NOTES

**pmNumberStr** returns a pointer to a static buffer and hence is not thread-safe. Multi-threaded applications should use **pmNumberStr\_r** instead.

## SEE ALSO

[**printf**(3)](/printf/3.md)
