annotate tests/testincludes/std/IEEE.d @ 1651:cb960b882ca3 default tip

bindings were moved to dsource.org/projects/bindings/
author Moritz Warning <moritzwarning@web.de>
date Thu, 20 May 2010 20:05:03 +0200
parents 628433c343b4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1595
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
1 // Written in the D programming language
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
2 /*
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
3 * Authors:
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
4 * Walter Bright, Don Clugston
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
5 * Copyright:
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
6 * Copyright (c) 2001-2005 by Digital Mars,
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
7 * All Rights Reserved,
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
8 * www.digitalmars.com
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
9 * License:
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
10 * This software is provided 'as-is', without any express or implied
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
11 * warranty. In no event will the authors be held liable for any damages
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
12 * arising from the use of this software.
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
13 *
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
14 * Permission is granted to anyone to use this software for any purpose,
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
15 * including commercial applications, and to alter it and redistribute it
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
16 * freely, subject to the following restrictions:
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
17 *
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
18 * <ul>
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
19 * <li> The origin of this software must not be misrepresented; you must not
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
20 * claim that you wrote the original software. If you use this software
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
21 * in a product, an acknowledgment in the product documentation would be
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
22 * appreciated but is not required.
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
23 * </li>
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
24 * <li> Altered source versions must be plainly marked as such, and must not
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
25 * be misrepresented as being the original software.
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
26 * </li>
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
27 * <li> This notice may not be removed or altered from any source
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
28 * distribution.
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
29 * </li>
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
30 * </ul>
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
31 */
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
32 /* Cut down version for libtangobos-partial/dstress */
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
33
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
34 module tango.math.IEEE;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
35
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
36
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
37 private:
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
38 /*
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
39 * The following IEEE 'real' formats are currently supported:
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
40 * 64 bit Big-endian 'double' (eg PowerPC)
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
41 * 128 bit Big-endian 'quadruple' (eg SPARC)
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
42 * 64 bit Little-endian 'double' (eg x86-SSE2)
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
43 * 80 bit Little-endian, with implied bit 'real80' (eg x87, Itanium).
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
44 * 128 bit Little-endian 'quadruple' (not implemented on any known processor!)
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
45 *
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
46 * Non-IEEE 128 bit Big-endian 'doubledouble' (eg PowerPC) has partial support
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
47 */
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
48 version(LittleEndian) {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
49 static assert(real.mant_dig == 53 || real.mant_dig==64
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
50 || real.mant_dig == 113,
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
51 "Only 64-bit, 80-bit, and 128-bit reals"
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
52 " are supported for LittleEndian CPUs");
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
53 } else {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
54 static assert(real.mant_dig == 53 || real.mant_dig==106
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
55 || real.mant_dig == 113,
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
56 "Only 64-bit and 128-bit reals are supported for BigEndian CPUs."
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
57 " double-double reals have partial support");
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
58 }
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
59
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
60 // Constants used for extracting the components of the representation.
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
61 // They supplement the built-in floating point properties.
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
62 template floatTraits(T) {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
63 // EXPMASK is a ushort mask to select the exponent portion (without sign)
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
64 // POW2MANTDIG = pow(2, real.mant_dig) is the value such that
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
65 // (smallest_denormal)*POW2MANTDIG == real.min
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
66 // EXPPOS_SHORT is the index of the exponent when represented as a ushort array.
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
67 // SIGNPOS_BYTE is the index of the sign when represented as a ubyte array.
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
68 static if (T.mant_dig == 24) { // float
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
69 const ushort EXPMASK = 0x7F80;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
70 const ushort EXPBIAS = 0x3F00;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
71 const uint EXPMASK_INT = 0x7F80_0000;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
72 const uint MANTISSAMASK_INT = 0x007F_FFFF;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
73 const real POW2MANTDIG = 0x1p+24;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
74 version(LittleEndian) {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
75 const EXPPOS_SHORT = 1;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
76 } else {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
77 const EXPPOS_SHORT = 0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
78 }
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
79 } else static if (T.mant_dig == 53) { // double, or real==double
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
80 const ushort EXPMASK = 0x7FF0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
81 const ushort EXPBIAS = 0x3FE0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
82 const uint EXPMASK_INT = 0x7FF0_0000;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
83 const uint MANTISSAMASK_INT = 0x000F_FFFF; // for the MSB only
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
84 const real POW2MANTDIG = 0x1p+53;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
85 version(LittleEndian) {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
86 const EXPPOS_SHORT = 3;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
87 const SIGNPOS_BYTE = 7;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
88 } else {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
89 const EXPPOS_SHORT = 0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
90 const SIGNPOS_BYTE = 0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
91 }
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
92 } else static if (T.mant_dig == 64) { // real80
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
93 const ushort EXPMASK = 0x7FFF;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
94 const ushort EXPBIAS = 0x3FFE;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
95 const real POW2MANTDIG = 0x1p+63;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
96 version(LittleEndian) {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
97 const EXPPOS_SHORT = 4;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
98 const SIGNPOS_BYTE = 9;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
99 } else {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
100 const EXPPOS_SHORT = 0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
101 const SIGNPOS_BYTE = 0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
102 }
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
103 } else static if (real.mant_dig == 113){ // quadruple
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
104 const ushort EXPMASK = 0x7FFF;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
105 const real POW2MANTDIG = 0x1p+113;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
106 version(LittleEndian) {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
107 const EXPPOS_SHORT = 7;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
108 const SIGNPOS_BYTE = 15;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
109 } else {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
110 const EXPPOS_SHORT = 0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
111 const SIGNPOS_BYTE = 0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
112 }
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
113 } else static if (real.mant_dig == 106) { // doubledouble
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
114 const ushort EXPMASK = 0x7FF0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
115 const real POW2MANTDIG = 0x1p+53; // doubledouble denormals are strange
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
116 // and the exponent byte is not unique
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
117 version(LittleEndian) {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
118 const EXPPOS_SHORT = 7; // [3] is also an exp short
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
119 const SIGNPOS_BYTE = 15;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
120 } else {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
121 const EXPPOS_SHORT = 0; // [4] is also an exp short
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
122 const SIGNPOS_BYTE = 0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
123 }
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
124 }
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
125 }
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
126
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
127
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
128 public:
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
129 /*********************************
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
130 * Return 1 if sign bit of e is set, 0 if not.
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
131 */
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
132
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
133 int signbit(real x)
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
134 {
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
135 return ((cast(ubyte *)&x)[floatTraits!(real).SIGNPOS_BYTE] & 0x80) != 0;
628433c343b4 Fixed DStress tests nocompile/c/{const_32_B.d,const_32_C.d}.
Robert Clipsham <robert@octarineparrot.com>
parents:
diff changeset
136 }