---
name: "gcvt"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/gcvt"
---

# gcvt(3)

convert a floating-point number to a string

## NAME

gcvt - convert a floating-point number to a string

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

```
#include <stdlib.h>
```

**char \*gcvt(double** *number***, int** *ndigit***, char \****buf***);**

Feature Test Macro Requirements for glibc (see [**feature\_test\_macros**(7)](/feature_test_macros/7.md)):

**gcvt**():

```
    Since glibc 2.17
        (_XOPEN_SOURCE >= 500 && ! (_POSIX_C_SOURCE >= 200809L))
            || /* glibc >= 2.20 */ _DEFAULT_SOURCE
            || /* glibc <= 2.19 */ _SVID_SOURCE
    glibc 2.12 to glibc 2.16:
        (_XOPEN_SOURCE >= 500 && ! (_POSIX_C_SOURCE >= 200112L))
            || _SVID_SOURCE
    Before glibc 2.12:
        _SVID_SOURCE || _XOPEN_SOURCE >= 500
```

## DESCRIPTION

The **gcvt**() function converts *number* to a minimal length null-terminated ASCII string and stores the result in *buf*. It produces *ndigit* significant digits in either [**printf**(3)](/printf/3.md) F format or E format.

## RETURN VALUE

The **gcvt**() function returns *buf*.

## ATTRIBUTES

For an explanation of the terms used in this section, see [**attributes**(7)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **gcvt**() | Thread safety | MT-Safe |

## STANDARDS

None.

## HISTORY

Marked as LEGACY in POSIX.1-2001. POSIX.1-2008 removed it, recommending the use of [**sprintf**(3)](/sprintf/3.md) instead (though [**snprintf**(3)](/snprintf/3.md) may be preferable).

## SEE ALSO

[**ecvt**(3)](/ecvt/3.md), [**fcvt**(3)](/fcvt/3.md), [**sprintf**(3)](/sprintf/3.md)
