Numeric Input Conversions (GNU Octave (version 6.1.90))

Next: String Input Conversions, Previous: Table of Input Conversions, Up: C-Style I/O Functions [Contents][Index]

#### 14.2.14 Numeric Input Conversions

This section describes the `scanf` conversions for reading numeric values.

The ‘`%d`’ conversion matches an optionally signed integer in decimal radix.

The ‘`%i`’ conversion matches an optionally signed integer in any of the formats that the C language defines for specifying an integer constant.

For example, any of the strings ‘`10`’, ‘`0xa`’, or ‘`012`’ could be read in as integers under the ‘`%i`’ conversion. Each of these specifies a number with decimal value `10`.

The ‘`%o`’, ‘`%u`’, and ‘`%x`’ conversions match unsigned integers in octal, decimal, and hexadecimal radices, respectively.

The ‘`%X`’ conversion is identical to the ‘`%x`’ conversion. They both permit either uppercase or lowercase letters to be used as digits.

By default, integers are read as 32-bit quantities. With the ‘`h`’ modifier, 16-bit integers are used, and with the ‘`l`’ modifier, 64-bit integers are used.

The ‘`%e`’, ‘`%f`’, ‘`%g`’, ‘`%E`’, and ‘`%G`’ conversions match optionally signed floating-point numbers. All five conversion specifications behave identically, and will read in numerical values of any floating point display style.