algoR

Undocumented in source. Be warned that the author may not have intended to support it.
package
@optStrategy("minsize")
T
algoR
(
T
W
WordEndian endian
)
(
T ret
,
scope BigUIntView!(const W, endian) coeff
,)

Examples

1 alias AliasSeq(T...) = T;
2 
3 foreach (T; AliasSeq!(float, double, real))
4 {{
5     T value = 3.518437208883201171875E+013;
6 
7 }}
8 
9 foreach(E; AliasSeq!(WordEndian.little, WordEndian.big))
10 foreach(W; AliasSeq!(ulong, uint, ushort, ubyte))
11 static if (!(E != TargetEndian && (W.sizeof > size_t.sizeof || W.sizeof == 1)))
12 {{
13     alias Args = AliasSeq!(W, E);
14 
15     auto view = DecimalView!Args(false, -8, BigUIntView!Args.fromHexString("BEBC2000000011E1A3"));
16 
17     assert (cast(float)view == 3.518437208883201171875E+013f);
18     assert (cast(double)view == 3.518437208883201171875E+013);
19     static if (real.mant_dig >= 64)
20         assert (cast(real)view == 3.518437208883201171875E+013L);
21 
22     view = DecimalView!Args(true, -169, BigUIntView!Args.fromHexString("5A174AEDA65CC"));
23     assert (cast(float)view == -0);
24     assert (cast(double)view == -0x1.1p-511);
25     static if (real.mant_dig >= 64)
26         assert (cast(real)view == -0x8.80000000000019fp-514L);
27 
28     view = DecimalView!Args(true, 293, BigUIntView!Args.fromHexString("36496F6C4ED38"));
29     assert (cast(float)view == -float.infinity);
30     assert (cast(double)view == -9.55024478104888e+307);
31     static if (real.mant_dig >= 64)
32         assert (cast(real)view == -9.55024478104888e+307L);
33 
34     view = DecimalView!Args(false, 0, BigUIntView!Args.fromHexString("1"));
35     assert (cast(float)view == 1);
36     assert (cast(double)view == 1);
37     static if (real.mant_dig >= 64)
38         assert (cast(real)view == 1L);
39 
40     view = DecimalView!Args(false, -5, BigUIntView!Args.fromHexString("3"));
41     assert (cast(float)view == 3e-5f);
42     assert (cast(double)view == 3e-5);
43     static if (real.mant_dig >= 64)
44         assert (cast(real)view == 3e-5L);
45 
46     view = DecimalView!Args(false, -1, BigUIntView!Args.fromHexString("1"));
47     assert (cast(float)view == 0.1f);
48     assert (cast(double)view == 0.1);
49     static if (real.mant_dig >= 64)
50         assert (cast(real)view == 0.1L);
51 
52     view = DecimalView!Args(false, 0, BigUIntView!Args.fromHexString("3039"));
53     assert (cast(float)view == 12345.0f);
54     assert (cast(double)view == 12345.0);
55     static if (real.mant_dig >= 64)
56         assert (cast(real)view == 12345.0L);
57 
58     view = DecimalView!Args(false, -7, BigUIntView!Args.fromHexString("98967F"));
59     assert (cast(float)view == 0.9999999f);
60     assert (cast(double)view == 0.9999999);
61     static if (real.mant_dig >= 64)
62         assert (cast(real)view == 0.9999999L);
63 
64     view = DecimalView!Args(false, -324, BigUIntView!Args.fromHexString("4F0CEDC95A718E"));
65     assert (cast(float)view == 0);
66     assert (cast(double)view == 2.2250738585072014e-308);
67     static if (real.mant_dig >= 64)
68         assert (cast(real)view == 2.2250738585072014e-308L);
69 
70     view = DecimalView!Args(false, 0, BigUIntView!Args.fromHexString("1FFFFFFFFFFFFFFFD"));
71     assert (cast(float)view == 36893488147419103229f);
72     assert (cast(double)view == 36893488147419103229.0);
73     static if (real.mant_dig >= 64)
74         assert (cast(real)view == 0x1FFFFFFFFFFFFFFFDp0L);
75 
76     view = DecimalView!Args(false, -33, BigUIntView!Args.fromHexString("65"));
77     assert (cast(float)view == 101e-33f);
78     assert (cast(double)view == 101e-33);
79     static if (real.mant_dig >= 64)
80         assert (cast(real)view == 101e-33L);
81 
82     view = DecimalView!Args(false, 23, BigUIntView!Args.fromHexString("1"));
83     assert (cast(float)view == 1e23f);
84     assert (cast(double)view == 1e23);
85     static if (real.mant_dig >= 64)
86         assert (cast(real)view == 1e23L);
87 
88     view = DecimalView!Args(false, 23, BigUIntView!Args.fromHexString("81B"));
89     assert (cast(float)view == 2075e23f);
90     assert (cast(double)view == 0xaba3d58a1f1a98p+32);
91     static if (real.mant_dig >= 64)
92         assert (cast(real)view == 0xaba3d58a1f1a9cp+32L);
93 
94     view = DecimalView!Args(false, -23, BigUIntView!Args.fromHexString("2209"));
95     assert (cast(float)view == 8713e-23f);
96     assert (cast(double)view == 0x1.9b75b4e7de2b9p-64);
97     static if (real.mant_dig >= 64)
98         assert (cast(real)view == 0xc.dbada73ef15c401p-67L);
99 
100     view = DecimalView!Args(false, 300, BigUIntView!Args.fromHexString("1"));
101     assert (cast(float)view == float.infinity);
102     assert (cast(double)view == 0x1.7e43c8800759cp+996);
103     static if (real.mant_dig >= 64)
104         assert (cast(real)view == 0xb.f21e44003acdd2dp+993L);
105 
106     view = DecimalView!Args(false, 245, BigUIntView!Args.fromHexString("B3A73CEB227"));
107     assert (cast(float)view == float.infinity);
108     assert (cast(double)view == 0x1.48e3735333cb6p+857);
109     static if (real.mant_dig >= 64)
110         assert (cast(real)view == 0xa.471b9a999e5b01ep+854L);
111 
112     view = DecimalView!Args(false, 0, BigUIntView!Args.fromHexString("88BF4748507FB9900ADB624CCFF8D78897DC900FB0460327D4D86D327219"));
113     assert (cast(float)view == float.infinity);
114     assert (cast(double)view == 0x1.117e8e90a0ff7p+239);
115     static if (real.mant_dig >= 64)
116         assert (cast(real)view == 0x8.8bf4748507fb99p+236L);
117 
118     view = DecimalView!Args(false, -324, BigUIntView!Args.fromHexString("5"));
119     assert (cast(float)view == 0);
120     assert (cast(double)view == 0x0.0000000000001p-1022);
121     static if (real.mant_dig >= 64)
122         assert (cast(real)view == 0x8.18995ce7aa0e1b2p-1077L);
123 
124     view = DecimalView!Args(false, -324, BigUIntView!Args.fromHexString("5B"));
125     assert (cast(float)view == 0);
126     assert (cast(double)view == 0x0.0000000000012p-1022);
127     static if (real.mant_dig >= 64)
128         assert (cast(real)view == 0x9.3594d9adeb09a55p-1073L);
129 
130     view = DecimalView!Args(false, -322, BigUIntView!Args.fromHexString("1"));
131     assert (cast(float)view == 0);
132     assert (cast(double)view == 0x0.0000000000014p-1022);
133     static if (real.mant_dig >= 64)
134         assert (cast(real)view == 0xa.1ebfb4219491a1fp-1073L);
135 
136     view = DecimalView!Args(false, -320, BigUIntView!Args.fromHexString("CA1CCB"));
137     assert (cast(float)view == 0);
138     assert (cast(double)view == 0x0.000063df832d9p-1022);
139     static if (real.mant_dig >= 64)
140         assert (cast(real)view == 0xc.7bf065b215888c7p-1043L);
141 
142     view = DecimalView!Args(false, -319, BigUIntView!Args.fromHexString("33CE7943FB"));
143     assert (cast(float)view == 0);
144     assert (cast(double)view == 0x1.000000000162p-1022);
145     static if (real.mant_dig >= 64)
146         assert (cast(real)view == 0x8.000000000b103b6p-1025L);
147 
148     view = DecimalView!Args(false, -309, BigUIntView!Args.fromHexString("15"));
149     assert (cast(float)view == 0);
150     assert (cast(double)view == 0x0.f19c2629ccf53p-1022);
151     static if (real.mant_dig >= 64)
152         assert (cast(real)view == 0xf.19c2629ccf52fc4p-1026L);
153 
154     view = DecimalView!Args(false, -340, BigUIntView!Args.fromHexString("AF87023B9BF0EE"));
155     assert (cast(float)view == 0);
156     assert (cast(double)view == 0x0.0000000000001p-1022);
157     static if (real.mant_dig >= 64)
158         assert (cast(real)view == 0xf.fffffffffffff64p-1078L);
159 
160     view = DecimalView!Args(false, 400, BigUIntView!Args.fromHexString("1"));
161     assert (cast(float)view == float.infinity);
162     assert (cast(double)view == double.infinity);
163     static if (real.mant_dig >= 64)
164         assert (cast(real)view == 0xd.a763fc8cb9ff9e6p+1325L);
165 
166     view = DecimalView!Args(false, 309, BigUIntView!Args.fromHexString("1"));
167     assert (cast(float)view == float.infinity);
168     assert (cast(double)view == double.infinity);
169     static if (real.mant_dig >= 64)
170         assert (cast(real)view == 0xb.201833b35d63f73p+1023L);
171 
172     view = DecimalView!Args(false, 308, BigUIntView!Args.fromHexString("2"));
173     assert (cast(float)view == float.infinity);
174     assert (cast(double)view == double.infinity);
175     static if (real.mant_dig >= 64)
176         assert (cast(real)view == 0x8.e679c2f5e44ff8fp+1021L);
177 
178     view = DecimalView!Args(false, 308, BigUIntView!Args.fromHexString("2"));
179     assert (cast(float)view == float.infinity);
180     assert (cast(double)view == double.infinity);
181     static if (real.mant_dig >= 64)
182         assert (cast(real)view == 0x8.e679c2f5e44ff8fp+1021L);
183 
184     view = DecimalView!Args(false, 295, BigUIntView!Args.fromHexString("1059949B7090"));
185     assert (cast(float)view == float.infinity);
186     assert (cast(double)view == double.infinity);
187     static if (real.mant_dig >= 64)
188         assert (cast(real)view == 0x8.00000000006955ap+1021L);
189 
190     view = DecimalView!Args(false, 0, BigUIntView!Args.fromHexString("0"));
191     assert (cast(float)view == 0);
192     assert (cast(double)view == 0);
193     static if (real.mant_dig >= 64)
194         assert (cast(real)view == 0L);
195 
196     view = DecimalView!Args(false, 0, BigUIntView!Args.init);
197     assert (cast(float)view == 0);
198     assert (cast(double)view == 0);
199     static if (real.mant_dig >= 64)
200         assert (cast(real)view == 0L);
201 
202     view = DecimalView!Args(false, -325, BigUIntView!Args.fromHexString("1"));
203     assert (cast(float)view == 0);
204     assert (cast(double)view == 0);
205     static if (real.mant_dig >= 64)
206         assert (cast(real)view == 0xa.5ced43b7e3e9188p-1083L);
207 
208     view = DecimalView!Args(false, -326, BigUIntView!Args.fromHexString("1"));
209     assert (cast(float)view == 0);
210     assert (cast(double)view == 0);
211     static if (real.mant_dig >= 64)
212         assert (cast(real)view == 0x8.4a57695fe98746dp-1086L);
213 
214     view = DecimalView!Args(false, -500, BigUIntView!Args.fromHexString("1"));
215     assert (cast(float)view == 0);
216     assert (cast(double)view == 0);
217     static if (real.mant_dig >= 64)
218         assert (cast(real)view == 0x8.33ada2003db9a8p-1664L);
219 
220     view = DecimalView!Args(false, -1000, BigUIntView!Args.fromHexString("1"));
221     assert (cast(float)view == 0);
222     assert (cast(double)view == 0);
223     static if (real.mant_dig >= 64)
224         assert (cast(real)view == 0x8.68a9188a89e1467p-3325L);
225 
226     view = DecimalView!Args(false, -4999, BigUIntView!Args.fromHexString("1"));
227     assert (cast(float)view == 0);
228     assert (cast(double)view == 0);
229     static if (real.mant_dig >= 64)
230         assert (cast(real)view == 0L);
231 
232     view = DecimalView!Args(false, -10000, BigUIntView!Args.fromHexString("1"));
233     assert (cast(float)view == 0);
234     assert (cast(double)view == 0);
235     static if (real.mant_dig >= 64)
236         assert (cast(real)view == 0L);
237 
238     view = DecimalView!Args(false, -4969, BigUIntView!Args.fromHexString("329659A941466C6B"));
239     assert (cast(float)view == 0);
240     assert (cast(double)view == 0);
241     static if (real.mant_dig >= 64)
242         assert (cast(real)view == real.min_normal * real.epsilon);
243 
244     view = DecimalView!Args(false, -15, BigUIntView!Args.fromHexString("525DB0200FFAB"));
245     assert (cast(float)view == 1.448997445238699f);
246     assert (cast(double)view == 0x1.72f17f1f49aadp+0);
247     static if (real.mant_dig >= 64)
248         assert (cast(real)view == 0xb.978bf8fa4d56cp-3L);
249 
250     view = DecimalView!Args(false, -15, BigUIntView!Args.fromHexString("525DB0200FFAB"));
251     assert (cast(float)view == 1.448997445238699f);
252     assert (cast(double)view == 0x1.72f17f1f49aadp+0);
253     static if (real.mant_dig >= 64)
254         assert (cast(real)view == 0xb.978bf8fa4d56cp-3L);
255 
256     view = DecimalView!Args(false, -325, BigUIntView!Args.fromHexString("1"));
257     assert (cast(float)view == 0);
258     assert (cast(double)view == 0);
259     static if (real.mant_dig >= 64)
260         assert (cast(real)view == 0xa.5ced43b7e3e9188p-1083L);
261 
262     view = DecimalView!Args(false, -326, BigUIntView!Args.fromHexString("1"));
263     assert (cast(float)view == 0);
264     assert (cast(double)view == 0);
265     static if (real.mant_dig >= 64)
266         assert (cast(real)view == 0x8.4a57695fe98746dp-1086L);
267 
268     view = DecimalView!Args(false, 0, BigUIntView!Args.fromHexString("1"));
269     assert (cast(float)view == 1);
270     assert (cast(double)view == 0x1p+0);
271     static if (real.mant_dig >= 64)
272         assert (cast(real)view == 0x8p-3L);
273 
274     view = DecimalView!Args(false, -5, BigUIntView!Args.fromHexString("3"));
275     assert (cast(float)view == 3e-5f);
276     assert (cast(double)view == 0x1.f75104d551d69p-16);
277     static if (real.mant_dig >= 64)
278         assert (cast(real)view == 0xf.ba8826aa8eb4635p-19L);
279 
280     view = DecimalView!Args(false, -1, BigUIntView!Args.fromHexString("1"));
281     assert (cast(float)view == 0.1f);
282     assert (cast(double)view == 0x1.999999999999ap-4);
283     static if (real.mant_dig >= 64)
284         assert (cast(real)view == 0xc.ccccccccccccccdp-7L);
285 
286     view = DecimalView!Args(false, -7, BigUIntView!Args.fromHexString("98967F"));
287     assert (cast(float)view == 0.9999999f);
288     assert (cast(double)view == 0x1.fffffca501acbp-1);
289     static if (real.mant_dig >= 64)
290         assert (cast(real)view == 0xf.ffffe5280d65435p-4L);
291 }}

Meta