Init
This commit is contained in:
53
cppdraft/conv/fpint.md
Normal file
53
cppdraft/conv/fpint.md
Normal file
@@ -0,0 +1,53 @@
|
||||
[conv.fpint]
|
||||
|
||||
# 7 Expressions [[expr]](./#expr)
|
||||
|
||||
## 7.3 Standard conversions [[conv]](conv#fpint)
|
||||
|
||||
### 7.3.11 Floating-integral conversions [conv.fpint]
|
||||
|
||||
[1](#1)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L989)
|
||||
|
||||
A prvalue of a floating-point type can be converted to a prvalue of an
|
||||
integer type[.](#1.sentence-1)
|
||||
|
||||
The conversion truncates; that is, the fractional part is
|
||||
discarded[.](#1.sentence-2)
|
||||
|
||||
The behavior is undefined if the truncated value cannot be represented
|
||||
in the destination type[.](#1.sentence-3)
|
||||
|
||||
[*Note [1](#note-1)*:
|
||||
|
||||
If the destination type is bool, see [[conv.bool]](conv.bool "7.3.15 Boolean conversions")[.](#1.sentence-4)
|
||||
|
||||
â *end note*]
|
||||
|
||||
[2](#2)
|
||||
|
||||
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/expressions.tex#L1001)
|
||||
|
||||
A prvalue of an integer type or of an unscoped enumeration type can be converted to
|
||||
a prvalue of a floating-point type[.](#2.sentence-1)
|
||||
|
||||
The result is exact if possible[.](#2.sentence-2)
|
||||
|
||||
If the value being
|
||||
converted is in the range of values that can be represented but the value cannot be
|
||||
represented exactly, it is an implementation-defined choice of either the next lower or higher representable
|
||||
value[.](#2.sentence-3)
|
||||
|
||||
[*Note [2](#note-2)*:
|
||||
|
||||
Loss of precision occurs if the integral value cannot be represented
|
||||
exactly as a value of the floating-point type[.](#2.sentence-4)
|
||||
|
||||
â *end note*]
|
||||
|
||||
If the value being converted is
|
||||
outside the range of values that can be represented, the behavior is undefined[.](#2.sentence-5)
|
||||
|
||||
If the
|
||||
source type is bool, the value false is converted to zero and the valuetrue is converted to one[.](#2.sentence-6)
|
||||
Reference in New Issue
Block a user