@@ -32,14 +32,14 @@ fn power_of_ten(e: i16) -> Fp {
3232 Fp { f : sig, e : exp }
3333}
3434
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.
3737#[ cfg( any( not( target_arch="x86" ) , target_feature="sse2" ) ) ]
3838mod fpu_precision {
3939 pub fn set_precision < T > ( ) { }
4040}
4141
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.
4343// The x87 FPU operates with 80 bits of precision by default, which means that operations will
4444// round to 80 bits causing double rounding to happen when values are eventually represented as
4545// 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 {
5454 ///
5555 /// The x87 FPU is a 16-bits register whose fields are as follows:
5656 ///
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 |
7260 ///
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).
7463 ///
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:
8066 /// - 0b00, single precision i.e. 32-bits
8167 /// - 0b10, double precision i.e. 64-bits
8268 /// - 0b11, double extended precision i.e. 80-bits (default state)
8369 /// 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)
9170 pub struct FPUControlWord ( u16 ) ;
9271
9372 fn set_cw ( cw : u16 ) {
0 commit comments