[istream.formatted.arithmetic]

# 31 Input/output library [[input.output]](./#input.output)

## 31.7 Formatting and manipulators [[iostream.format]](iostream.format#istream.formatted.arithmetic)

### 31.7.5 Input streams [[input.streams]](input.streams#istream.formatted.arithmetic)

#### 31.7.5.3 Formatted input functions [[istream.formatted]](istream.formatted#arithmetic)

#### 31.7.5.3.2 Arithmetic extractors [istream.formatted.arithmetic]

[ð](#lib:operator%3e%3e,basic_istream)

`basic_istream& operator>>(unsigned short& val);
basic_istream& operator>>(unsigned int& val);
basic_istream& operator>>(long& val);
basic_istream& operator>>(unsigned long& val);
basic_istream& operator>>(long long& val);
basic_istream& operator>>(unsigned long long& val);
basic_istream& operator>>(float& val);
basic_istream& operator>>(double& val);
basic_istream& operator>>(long double& val);
basic_istream& operator>>(bool& val);
basic_istream& operator>>(void*& val);
`

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4713)

As in the case of the inserters, these extractors depend on the
locale's[num_get<>](locale.num.get "28.3.4.3.2 Class template num_­get [locale.num.get]") object to perform parsing the input
stream data[.](#1.sentence-1)

These extractors behave as formatted input functions (as described in [[istream.formatted.reqmts]](istream.formatted.reqmts "31.7.5.3.1 Common requirements"))[.](#1.sentence-2)

After a sentry object is constructed, the
conversion occurs as if performed by the following code fragment,
where state represents the input function's local error state:using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
use_facet<numget>(loc).get(*this, 0, *this, state, val);

In the above fragment,loc stands for the private member of thebasic_ios class[.](#1.sentence-4)

[*Note [1](#note-1)*:

The first argument provides an object of theistreambuf_iterator class which is an iterator pointed to an input stream[.](#1.sentence-5)

It bypasses istreams and uses streambufs directly[.](#1.sentence-6)

â *end note*]

Classlocale relies on this
type as its interface toistream,
so that it does not need to depend directly onistream[.](#1.sentence-7)

[ð](#lib:operator%3e%3e,basic_istream_)

`basic_istream& operator>>(short& val);
`

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4751)

The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;long lval;
use_facet<numget>(loc).get(*this, 0, *this, state, lval);if (lval < numeric_limits<short>::min()) { state |= ios_base::failbit;
 val = numeric_limits<short>::min();} else if (numeric_limits<short>::max() < lval) { state |= ios_base::failbit;
 val = numeric_limits<short>::max();} else val = static_cast<short>(lval);

[ð](#lib:operator%3e%3e,basic_istream__)

`basic_istream& operator>>(int& val);
`

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4775)

The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;long lval;
use_facet<numget>(loc).get(*this, 0, *this, state, lval);if (lval < numeric_limits<int>::min()) { state |= ios_base::failbit;
 val = numeric_limits<int>::min();} else if (numeric_limits<int>::max() < lval) { state |= ios_base::failbit;
 val = numeric_limits<int>::max();} else val = static_cast<int>(lval);

[ð](#itemdecl:4)

`basic_istream& operator>>(extended-floating-point-type& val);
`

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4798)

If
the floating-point conversion rank of *extended-floating-point-type* is not less than or equal to that of long double,
then an invocation of the operator function is conditionally supported
with implementation-defined
semantics[.](#4.sentence-1)

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4806)

Otherwise, let FP be a standard floating-point type:

- [(5.1)](#5.1)

if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of float,
then FP is float,

- [(5.2)](#5.2)

otherwise,
if the floating-point conversion rank of *extended-floating-point-type* is less than or equal to that of double,
then FP is double,

- [(5.3)](#5.3)

otherwise, FP is long double[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iostreams.tex#L4822)

The conversion occurs as if performed by the following code fragment
(using the same notation as for the preceding code fragment):using numget = num_get<charT, istreambuf_iterator<charT, traits>>;
FP fval;
use_facet<numget>(loc).get(*this, 0, *this, state, fval);if (fval < -numeric_limits<*extended-floating-point-type*>::max()) { state |= ios_base::failbit;
 val = -numeric_limits<*extended-floating-point-type*>::max();} else if (numeric_limits<*extended-floating-point-type*>::max() < fval) { state |= ios_base::failbit;
 val = numeric_limits<*extended-floating-point-type*>::max();} else { val = static_cast<*extended-floating-point-type*>(fval);}

[*Note [2](#note-2)*:

When the extended floating-point type has
a floating-point conversion rank
that is not equal to the rank of any standard floating-point type,
then double rounding during the conversion can result in inaccurate results[.](#6.sentence-1)

from_chars can be used in situations
where maximum accuracy is important[.](#6.sentence-2)

â *end note*]
