Function: number-to-string

number-to-string is a function defined in data.c.

Signature

(number-to-string NUMBER)

Documentation

Return the decimal representation of NUMBER as a string.

Uses a minus sign if negative. NUMBER may be an integer or a floating point number.

Other relevant functions are documented in the string group.

View in manual

Probably introduced at or before Emacs version 19.29.

Shortdoc

;; string
(number-to-string 42)
    => "42"

Aliases

int-to-string

Source Code

// Defined in /usr/src/emacs/src/data.c
{
  char buffer[max (FLOAT_TO_STRING_BUFSIZE, INT_BUFSIZE_BOUND (EMACS_INT))];

  if (FIXNUMP (number))
    {
      char *end = buffer + sizeof buffer;
      char *p = fixnum_to_string (XFIXNUM (number), buffer, end);
      return make_unibyte_string (p, end - p);
    }

  if (BIGNUMP (number))
    return bignum_to_string (number, 10);

  if (FLOATP (number))
    return make_unibyte_string (buffer,
				float_to_string (buffer, XFLOAT_DATA (number)));

  wrong_type_argument (Qnumberp, number);
}