|
1 | 1 | <!--{
|
2 | 2 | "Title": "The Go Programming Language Specification",
|
3 |
| - "Subtitle": "Version of April 12, 2017", |
| 3 | + "Subtitle": "Version of April 17, 2017", |
4 | 4 | "Path": "/ref/spec"
|
5 | 5 | }-->
|
6 | 6 |
|
@@ -3582,6 +3582,33 @@ <h4 id="Floating_point_operators">Floating-point operators</h4>
|
3582 | 3582 | occurs is implementation-specific.
|
3583 | 3583 | </p>
|
3584 | 3584 |
|
| 3585 | +<p> |
| 3586 | +An implementation may combine multiple floating-point operations into a single |
| 3587 | +fused operation, possibly across statements, and produce a result that differs |
| 3588 | +from the value obtained by executing and rounding the instructions individually. |
| 3589 | +A floating-point type <a href="#Conversions">conversion</a> explicitly rounds to |
| 3590 | +the precision of the target type, preventing fusion that would discard that rounding. |
| 3591 | +</p> |
| 3592 | + |
| 3593 | +<p> |
| 3594 | +For instance, some architectures provide a "fused multiply and add" (FMA) instruction |
| 3595 | +that computes <code>x*y + z</code> without rounding the intermediate result <code>x*y</code>. |
| 3596 | +These examples show when a Go implementation can use that instruction: |
| 3597 | +</p> |
| 3598 | + |
| 3599 | +<pre> |
| 3600 | +// FMA allowed for computing r, because x*y is not explicitly rounded: |
| 3601 | +r = x*y + z |
| 3602 | +r = z; r += x*y |
| 3603 | +t = x*y; r = t + z |
| 3604 | +*p = x*y; r = *p + z |
| 3605 | +r = x*y + float64(z) |
| 3606 | + |
| 3607 | +// FMA disallowed for computing r, because it would omit rounding of x*y: |
| 3608 | +r = float64(x*y) + z |
| 3609 | +r = z; r += float64(x*y) |
| 3610 | +t = float64(x*y); r = t + z |
| 3611 | +</pre> |
3585 | 3612 |
|
3586 | 3613 | <h4 id="String_concatenation">String concatenation</h4>
|
3587 | 3614 |
|
@@ -3640,7 +3667,7 @@ <h3 id="Comparison_operators">Comparison operators</h3>
|
3640 | 3667 | </li>
|
3641 | 3668 |
|
3642 | 3669 | <li>
|
3643 |
| - Floating point values are comparable and ordered, |
| 3670 | + Floating-point values are comparable and ordered, |
3644 | 3671 | as defined by the IEEE-754 standard.
|
3645 | 3672 | </li>
|
3646 | 3673 |
|
|
0 commit comments