1
1
Ddoc
2
2
3
- $(SPEC_S Floating Point,
3
+ $(SPEC_S Floating- Point,
4
4
5
5
$(HEADERNAV_TOC)
6
6
7
- $(H2 $(LNAME2 fp_intermediate_values, Floating Point Intermediate Values))
7
+ $(H2 $(LNAME2 fp_intermediate_values, Floating- Point Intermediate Values))
8
8
9
- $(P On many computers, greater
10
- precision operations do not take any longer than lesser
11
- precision operations, so it makes numerical sense to use
12
- the greatest precision available for internal temporaries.
13
- The philosophy is not to dumb down the language to the lowest
14
- common hardware denominator, but to enable the exploitation
15
- of the best capabilities of target hardware.
16
- )
17
-
18
- $(P For floating point operations and expression intermediate values,
9
+ $(P For floating-point operations and expression intermediate values,
19
10
a greater precision can be used than the type of the
20
11
expression.
21
12
Only the minimum precision is set by the types of the
@@ -26,31 +17,17 @@ $(H2 $(LNAME2 fp_intermediate_values, Floating Point Intermediate Values))
26
17
implemented by the hardware.
27
18
)
28
19
29
- $(P It's possible that, due to greater use of temporaries and
30
- common subexpressions, optimized code may produce a more
31
- accurate answer than unoptimized code.
32
- )
33
-
34
- $(P Algorithms should be written to work based on the minimum
35
- precision of the calculation. They should not degrade or
36
- fail if the actual precision is greater. Float or double types,
37
- as opposed to the real (extended) type, should only be used for:
38
- )
39
-
40
- $(UL
41
- $(LI reducing memory consumption for large arrays)
42
- $(LI when speed is more important than accuracy)
43
- $(LI data and function argument compatibility with C)
44
- )
20
+ $(P Execution of floating-point expressions may yield a result of greater precision than dictated
21
+ by the source.)
45
22
46
- $(H2 $(LNAME2 fp_const_folding, Floating Point Constant Folding))
23
+ $(H2 $(LNAME2 fp_const_folding, Floating- Point Constant Folding))
47
24
48
- $(P Regardless of the type of the operands, floating point
25
+ $(P Regardless of the type of the operands, floating- point
49
26
constant folding is done in $(D real) or greater precision.
50
- It is always done following IEEE 754 rules and round-to-nearest
27
+ It is always done following $(LINK2 https://standards.ieee.org/standard/ 754-2019.html, IEEE-754) rules and round-to-nearest
51
28
is used.)
52
29
53
- $(P Floating point constants are internally represented in
30
+ $(P Floating- point constants are internally represented in
54
31
the implementation in at least $(D real) precision, regardless
55
32
of the constant's type. The extra precision is available for
56
33
constant folding. Committing to the precision of the result is
@@ -67,8 +44,8 @@ writeln(f - 0.2);
67
44
static float f = 0.2f;
68
45
writeln(f - 0.2);
69
46
---
70
- $(P will print 2.98023e-09. Hex floating point constants can also
71
- be used when specific floating point bit patterns are needed that
47
+ $(P will print 2.98023e-09. Hex floating- point constants can also
48
+ be used when specific floating- point bit patterns are needed that
72
49
are unaffected by rounding. To find the hex value of 0.2f:)
73
50
74
51
---
@@ -90,12 +67,12 @@ writeln(f - 0.2);
90
67
91
68
$(P Different compiler settings, optimization settings,
92
69
and inlining settings can affect opportunities for constant
93
- folding, therefore the results of floating point calculations may differ
70
+ folding, therefore the results of floating- point calculations may differ
94
71
depending on those settings.)
95
72
96
73
$(H2 $(LNAME2 rounding_control, Rounding Control))
97
74
98
- $(P IEEE 754 floating point arithmetic includes the ability to set 4
75
+ $(P IEEE 754 floating- point arithmetic includes the ability to set 4
99
76
different rounding modes.
100
77
These are accessible via the functions in $(D core.stdc.fenv).
101
78
)
@@ -107,9 +84,9 @@ $(H2 $(LNAME2 rounding_control, Rounding Control))
107
84
)
108
85
109
86
110
- $(H2 $(LNAME2 esception_flags , Exception Flags))
87
+ $(H2 $(LNAME2 exception_flags , Exception Flags))
111
88
112
- $(P IEEE 754 floating point arithmetic can set several flags based on what
89
+ $(P IEEE 754 floating- point arithmetic can set several flags based on what
113
90
happened with a
114
91
computation:)
115
92
@@ -124,22 +101,19 @@ $(H2 $(LNAME2 esception_flags, Exception Flags))
124
101
125
102
$(P These flags can be set/reset via the functions in $(D core.stdc.fenv).)
126
103
127
- $(H2 $(LNAME2 floating-point-transformations, Floating Point Transformations))
104
+ $(H2 $(LNAME2 floating-point-transformations, Floating- Point Transformations))
128
105
129
106
$(P An implementation may perform transformations on
130
- floating point computations in order to reduce their strength,
131
- i.e. their runtime computation time.
132
- Because floating point math does not precisely follow mathematical
133
- rules, some transformations are not valid, even though some
134
- other programming languages still allow them.
107
+ floating-point computations in order to reduce their strength.
135
108
)
136
109
137
- $(P The following transformations of floating point expressions
110
+ $(P Not all transformations are valid: The following
111
+ transformations of floating-point expressions
138
112
are not allowed because under IEEE rules they could produce
139
113
different results.
140
114
)
141
115
142
- $(TABLE2 Disallowed Floating Point Transformations,
116
+ $(TABLE2 Disallowed Floating- Point Transformations,
143
117
$(THEAD transformation, comments)
144
118
$(TROW
145
119
$(ARGS $(I x) + 0 $(RARR) $(I x)) , $(ARGS not valid if $(I x) is -0)
@@ -186,4 +160,4 @@ $(SPEC_SUBNAV_PREV_NEXT garbage, Garbage Collection, iasm, D x86 Inline Assemble
186
160
187
161
Macros:
188
162
CHAPTER=29
189
- TITLE=Floating Point
163
+ TITLE=Floating- Point
0 commit comments