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.
© 1996–2020 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/v6.3.0/Numeric-Input-Conversions.html