@@ -32,14 +32,14 @@ fn power_of_ten(e: i16) -> Fp {
32
32
Fp { f : sig, e : exp }
33
33
}
34
34
35
- // Most architectures floating point operations with explicit bit size, therefore the precision of
36
- // the computation is determined on a per-operation basis.
35
+ // In most architectures, floating point operations have an explicit bit size, therefore the
36
+ // precision of the computation is determined on a per-operation basis.
37
37
#[ cfg( any( not( target_arch="x86" ) , target_feature="sse2" ) ) ]
38
38
mod fpu_precision {
39
39
pub fn set_precision < T > ( ) { }
40
40
}
41
41
42
- // On x86, the x87 FPU is used for float operations if the SSE[2] extensions are not available.
42
+ // On x86, the x87 FPU is used for float operations if the SSE/SSE2 extensions are not available.
43
43
// The x87 FPU operates with 80 bits of precision by default, which means that operations will
44
44
// round to 80 bits causing double rounding to happen when values are eventually represented as
45
45
// 32/64 bit float values. To overcome this, the FPU control word can be set so that the
@@ -54,40 +54,19 @@ mod fpu_precision {
54
54
///
55
55
/// The x87 FPU is a 16-bits register whose fields are as follows:
56
56
///
57
- /// 1111 11
58
- /// 5432 10 98 76 5 4 3 2 1 0
59
- /// +----+--+--+--+-+-+-+-+-+-+
60
- /// | |RC|PC| |P|U|O|Z|D|I|
61
- /// | | | | |M|M|M|M|M|M|
62
- /// +----+--+--+--+-+-+-+-+-+-+
63
- /// The fields are:
64
- /// - Invalid operation Mask
65
- /// - Denormal operand Mask
66
- /// - Zero divide Mask
67
- /// - Overflow Mask
68
- /// - Underflow Mask
69
- /// - Precision Mask
70
- /// - Precision Control
71
- /// - Rounding Control
57
+ /// | 12-15 | 10-11 | 8-9 | 6-7 | 5 | 4 | 3 | 2 | 1 | 0 |
58
+ /// |------:|------:|----:|----:|---:|---:|---:|---:|---:|---:|
59
+ /// | | RC | PC | | PM | UM | OM | ZM | DM | IM |
72
60
///
73
- /// The fields with no name are unused (on FPUs more modern than 287).
61
+ /// The documentation for all of the fields is available in the IA-32 Architectures Software
62
+ /// Developer's Manual (Volume 1).
74
63
///
75
- /// The 6 LSBs (bits 0-5) are the exception mask bits; each blocks a specific type of floating
76
- /// point exceptions from being raised.
77
- ///
78
- /// The Precision Control field determines the precision of the operations performed by the
79
- /// FPU. It can set to:
64
+ /// The only field which is relevant for the following code is PC, Precision Control. This
65
+ /// field determines the precision of the operations performed by the FPU. It can be set to:
80
66
/// - 0b00, single precision i.e. 32-bits
81
67
/// - 0b10, double precision i.e. 64-bits
82
68
/// - 0b11, double extended precision i.e. 80-bits (default state)
83
69
/// The 0b01 value is reserved and should not be used.
84
- ///
85
- /// The Rounding Control field determines how values which cannot be represented exactly are
86
- /// rounded. It can be set to:
87
- /// - 0b00, round to nearest even (default state)
88
- /// - 0b01, round down (toward -inf)
89
- /// - 0b10, round up (toward +inf)
90
- /// - 0b11, round toward 0 (truncate)
91
70
pub struct FPUControlWord ( u16 ) ;
92
71
93
72
fn set_cw ( cw : u16 ) {
0 commit comments