1 | // Copyright (c) Microsoft Corporation. |
2 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
3 | |
4 | |
5 | // Copyright 2018 Ulf Adams |
6 | // Copyright (c) Microsoft Corporation. All rights reserved. |
7 | |
8 | // Boost Software License - Version 1.0 - August 17th, 2003 |
9 | |
10 | // Permission is hereby granted, free of charge, to any person or organization |
11 | // obtaining a copy of the software and accompanying documentation covered by |
12 | // this license (the "Software") to use, reproduce, display, distribute, |
13 | // execute, and transmit the Software, and to prepare derivative works of the |
14 | // Software, and to permit third-parties to whom the Software is furnished to |
15 | // do so, all subject to the following: |
16 | |
17 | // The copyright notices in the Software and this entire statement, including |
18 | // the above license grant, this restriction and the following disclaimer, |
19 | // must be included in all copies of the Software, in whole or in part, and |
20 | // all derivative works of the Software, unless such copies or derivative |
21 | // works are solely in the form of machine-executable object code generated by |
22 | // a source language processor. |
23 | |
24 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
25 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
26 | // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
27 | // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
28 | // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
29 | // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
30 | // DEALINGS IN THE SOFTWARE. |
31 | |
32 | |
33 | // This file contains test cases derived from: |
34 | // https://github.com/ulfjack/ryu |
35 | // See xcharconv_ryu.h for the exact commit. |
36 | // (Keep the cgmanifest.json commitHash in sync.) |
37 | |
38 | |
39 | #ifndef FLOAT_TO_CHARS_TEST_CASES_HPP |
40 | #define FLOAT_TO_CHARS_TEST_CASES_HPP |
41 | |
42 | #include <charconv> |
43 | |
44 | #include "test.hpp" |
45 | using namespace std; |
46 | |
47 | inline constexpr FloatToCharsTestCase float_to_chars_test_cases[] = { |
48 | // Test special cases (zero, inf, nan) and an ordinary case. Also test negative signs. |
49 | {.value: 0.0f, .fmt: chars_format::scientific, .correct: "0e+00" }, |
50 | {.value: -0.0f, .fmt: chars_format::scientific, .correct: "-0e+00" }, |
51 | {.value: float_inf, .fmt: chars_format::scientific, .correct: "inf" }, |
52 | {.value: -float_inf, .fmt: chars_format::scientific, .correct: "-inf" }, |
53 | {.value: float_nan, .fmt: chars_format::scientific, .correct: "nan" }, |
54 | {.value: -float_nan, .fmt: chars_format::scientific, .correct: "-nan(ind)" }, |
55 | {.value: float_nan_payload, .fmt: chars_format::scientific, .correct: "nan" }, |
56 | {.value: -float_nan_payload, .fmt: chars_format::scientific, .correct: "-nan" }, |
57 | {.value: 2.018f, .fmt: chars_format::scientific, .correct: "2.018e+00" }, |
58 | {.value: -2.018f, .fmt: chars_format::scientific, .correct: "-2.018e+00" }, |
59 | |
60 | // Ditto for fixed, which doesn't emit exponents. |
61 | {.value: 0.0f, .fmt: chars_format::fixed, .correct: "0" }, |
62 | {.value: -0.0f, .fmt: chars_format::fixed, .correct: "-0" }, |
63 | {.value: float_inf, .fmt: chars_format::fixed, .correct: "inf" }, |
64 | {.value: -float_inf, .fmt: chars_format::fixed, .correct: "-inf" }, |
65 | {.value: float_nan, .fmt: chars_format::fixed, .correct: "nan" }, |
66 | {.value: -float_nan, .fmt: chars_format::fixed, .correct: "-nan(ind)" }, |
67 | {.value: float_nan_payload, .fmt: chars_format::fixed, .correct: "nan" }, |
68 | {.value: -float_nan_payload, .fmt: chars_format::fixed, .correct: "-nan" }, |
69 | {.value: 2.018f, .fmt: chars_format::fixed, .correct: "2.018" }, |
70 | {.value: -2.018f, .fmt: chars_format::fixed, .correct: "-2.018" }, |
71 | |
72 | // Ditto for general, which selects fixed for the scientific exponent 0. |
73 | {.value: 0.0f, .fmt: chars_format::general, .correct: "0" }, |
74 | {.value: -0.0f, .fmt: chars_format::general, .correct: "-0" }, |
75 | {.value: float_inf, .fmt: chars_format::general, .correct: "inf" }, |
76 | {.value: -float_inf, .fmt: chars_format::general, .correct: "-inf" }, |
77 | {.value: float_nan, .fmt: chars_format::general, .correct: "nan" }, |
78 | {.value: -float_nan, .fmt: chars_format::general, .correct: "-nan(ind)" }, |
79 | {.value: float_nan_payload, .fmt: chars_format::general, .correct: "nan" }, |
80 | {.value: -float_nan_payload, .fmt: chars_format::general, .correct: "-nan" }, |
81 | {.value: 2.018f, .fmt: chars_format::general, .correct: "2.018" }, |
82 | {.value: -2.018f, .fmt: chars_format::general, .correct: "-2.018" }, |
83 | |
84 | // Ditto for plain, which selects fixed because it's shorter for these values. |
85 | {.value: 0.0f, .fmt: chars_format{}, .correct: "0" }, |
86 | {.value: -0.0f, .fmt: chars_format{}, .correct: "-0" }, |
87 | {.value: float_inf, .fmt: chars_format{}, .correct: "inf" }, |
88 | {.value: -float_inf, .fmt: chars_format{}, .correct: "-inf" }, |
89 | {.value: float_nan, .fmt: chars_format{}, .correct: "nan" }, |
90 | {.value: -float_nan, .fmt: chars_format{}, .correct: "-nan(ind)" }, |
91 | {.value: float_nan_payload, .fmt: chars_format{}, .correct: "nan" }, |
92 | {.value: -float_nan_payload, .fmt: chars_format{}, .correct: "-nan" }, |
93 | {.value: 2.018f, .fmt: chars_format{}, .correct: "2.018" }, |
94 | {.value: -2.018f, .fmt: chars_format{}, .correct: "-2.018" }, |
95 | |
96 | // Ditto for hex. |
97 | {.value: 0.0f, .fmt: chars_format::hex, .correct: "0p+0" }, |
98 | {.value: -0.0f, .fmt: chars_format::hex, .correct: "-0p+0" }, |
99 | {.value: float_inf, .fmt: chars_format::hex, .correct: "inf" }, |
100 | {.value: -float_inf, .fmt: chars_format::hex, .correct: "-inf" }, |
101 | {.value: float_nan, .fmt: chars_format::hex, .correct: "nan" }, |
102 | {.value: -float_nan, .fmt: chars_format::hex, .correct: "-nan(ind)" }, |
103 | {.value: float_nan_payload, .fmt: chars_format::hex, .correct: "nan" }, |
104 | {.value: -float_nan_payload, .fmt: chars_format::hex, .correct: "-nan" }, |
105 | {.value: 0x1.729p+0f, .fmt: chars_format::hex, .correct: "1.729p+0" }, |
106 | {.value: -0x1.729p+0f, .fmt: chars_format::hex, .correct: "-1.729p+0" }, |
107 | |
108 | // Ryu f2s_test.cc SwitchToSubnormal |
109 | {.value: 1.1754944e-38f, .fmt: chars_format::scientific, .correct: "1.1754944e-38" }, |
110 | |
111 | // Ryu f2s_test.cc MinAndMax |
112 | {.value: 0x1.fffffep+127f, .fmt: chars_format::scientific, .correct: "3.4028235e+38" }, |
113 | {.value: 0x1.000000p-149f, .fmt: chars_format::scientific, .correct: "1e-45" }, |
114 | |
115 | // Ryu f2s_test.cc BoundaryRoundEven |
116 | {.value: 3.355445e7f, .fmt: chars_format::scientific, .correct: "3.355445e+07" }, |
117 | {.value: 8.999999e9f, .fmt: chars_format::scientific, .correct: "9e+09" }, |
118 | {.value: 3.4366717e10f, .fmt: chars_format::scientific, .correct: "3.436672e+10" }, |
119 | |
120 | // Ryu f2s_test.cc ExactValueRoundEven |
121 | {.value: 3.0540412e5f, .fmt: chars_format::scientific, .correct: "3.0540412e+05" }, |
122 | {.value: 8.0990312e3f, .fmt: chars_format::scientific, .correct: "8.0990312e+03" }, |
123 | |
124 | // Ryu f2s_test.cc LotsOfTrailingZeros |
125 | {.value: 2.4414062e-4f, .fmt: chars_format::scientific, .correct: "2.4414062e-04" }, |
126 | {.value: 2.4414062e-3f, .fmt: chars_format::scientific, .correct: "2.4414062e-03" }, |
127 | {.value: 4.3945312e-3f, .fmt: chars_format::scientific, .correct: "4.3945312e-03" }, |
128 | {.value: 6.3476562e-3f, .fmt: chars_format::scientific, .correct: "6.3476562e-03" }, |
129 | |
130 | // Ryu f2s_test.cc Regression |
131 | {.value: 4.7223665e21f, .fmt: chars_format::scientific, .correct: "4.7223665e+21" }, |
132 | {.value: 8388608.0f, .fmt: chars_format::scientific, .correct: "8.388608e+06" }, |
133 | {.value: 1.6777216e7f, .fmt: chars_format::scientific, .correct: "1.6777216e+07" }, |
134 | {.value: 3.3554436e7f, .fmt: chars_format::scientific, .correct: "3.3554436e+07" }, |
135 | {.value: 6.7131496e7f, .fmt: chars_format::scientific, .correct: "6.7131496e+07" }, |
136 | {.value: 1.9310392e-38f, .fmt: chars_format::scientific, .correct: "1.9310392e-38" }, |
137 | {.value: -2.47e-43f, .fmt: chars_format::scientific, .correct: "-2.47e-43" }, |
138 | {.value: 1.993244e-38f, .fmt: chars_format::scientific, .correct: "1.993244e-38" }, |
139 | {.value: 4103.9003f, .fmt: chars_format::scientific, .correct: "4.1039004e+03" }, |
140 | {.value: 5.3399997e9f, .fmt: chars_format::scientific, .correct: "5.3399997e+09" }, |
141 | {.value: 6.0898e-39f, .fmt: chars_format::scientific, .correct: "6.0898e-39" }, |
142 | {.value: 0.0010310042f, .fmt: chars_format::scientific, .correct: "1.0310042e-03" }, |
143 | {.value: 2.8823261e17f, .fmt: chars_format::scientific, .correct: "2.882326e+17" }, |
144 | {.value: 0x1.5c87fap-84f, .fmt: chars_format::scientific, .correct: "7.038531e-26" }, // TRANSITION, VSO-629490, should be 7.038531e-26f |
145 | {.value: 9.2234038e17f, .fmt: chars_format::scientific, .correct: "9.223404e+17" }, |
146 | {.value: 6.7108872e7f, .fmt: chars_format::scientific, .correct: "6.710887e+07" }, |
147 | {.value: 1.0e-44f, .fmt: chars_format::scientific, .correct: "1e-44" }, |
148 | {.value: 2.816025e14f, .fmt: chars_format::scientific, .correct: "2.816025e+14" }, |
149 | {.value: 9.223372e18f, .fmt: chars_format::scientific, .correct: "9.223372e+18" }, |
150 | {.value: 1.5846085e29f, .fmt: chars_format::scientific, .correct: "1.5846086e+29" }, |
151 | {.value: 1.1811161e19f, .fmt: chars_format::scientific, .correct: "1.1811161e+19" }, |
152 | {.value: 5.368709e18f, .fmt: chars_format::scientific, .correct: "5.368709e+18" }, |
153 | {.value: 4.6143165e18f, .fmt: chars_format::scientific, .correct: "4.6143166e+18" }, |
154 | {.value: 0.007812537f, .fmt: chars_format::scientific, .correct: "7.812537e-03" }, |
155 | {.value: 1.4e-45f, .fmt: chars_format::scientific, .correct: "1e-45" }, |
156 | {.value: 1.18697724e20f, .fmt: chars_format::scientific, .correct: "1.18697725e+20" }, |
157 | {.value: 1.00014165e-36f, .fmt: chars_format::scientific, .correct: "1.00014165e-36" }, |
158 | {.value: 200.0f, .fmt: chars_format::scientific, .correct: "2e+02" }, |
159 | {.value: 3.3554432e7f, .fmt: chars_format::scientific, .correct: "3.3554432e+07" }, |
160 | |
161 | // Ryu f2s_test.cc LooksLikePow5 |
162 | {.value: 0x1.2a05f2p+59f, .fmt: chars_format::scientific, .correct: "6.7108864e+17" }, |
163 | {.value: 0x1.2a05f2p+60f, .fmt: chars_format::scientific, .correct: "1.3421773e+18" }, |
164 | {.value: 0x1.2a05f2p+61f, .fmt: chars_format::scientific, .correct: "2.6843546e+18" }, |
165 | |
166 | // Ryu f2s_test.cc OutputLength |
167 | {.value: 1.0f, .fmt: chars_format::scientific, .correct: "1e+00" }, |
168 | {.value: 1.2f, .fmt: chars_format::scientific, .correct: "1.2e+00" }, |
169 | {.value: 1.23f, .fmt: chars_format::scientific, .correct: "1.23e+00" }, |
170 | {.value: 1.234f, .fmt: chars_format::scientific, .correct: "1.234e+00" }, |
171 | {.value: 1.2345f, .fmt: chars_format::scientific, .correct: "1.2345e+00" }, |
172 | {.value: 1.23456f, .fmt: chars_format::scientific, .correct: "1.23456e+00" }, |
173 | {.value: 1.234567f, .fmt: chars_format::scientific, .correct: "1.234567e+00" }, |
174 | {.value: 1.2345678f, .fmt: chars_format::scientific, .correct: "1.2345678e+00" }, |
175 | {.value: 1.23456735e-36f, .fmt: chars_format::scientific, .correct: "1.23456735e-36" }, |
176 | |
177 | // Test all exponents. |
178 | {.value: 1.729e-45f, .fmt: chars_format::scientific, .correct: "1e-45" }, |
179 | {.value: 1.729e-44f, .fmt: chars_format::scientific, .correct: "1.7e-44" }, |
180 | {.value: 1.729e-43f, .fmt: chars_format::scientific, .correct: "1.72e-43" }, |
181 | {.value: 1.729e-42f, .fmt: chars_format::scientific, .correct: "1.729e-42" }, |
182 | {.value: 1.729e-41f, .fmt: chars_format::scientific, .correct: "1.729e-41" }, |
183 | {.value: 1.729e-40f, .fmt: chars_format::scientific, .correct: "1.729e-40" }, |
184 | {.value: 1.729e-39f, .fmt: chars_format::scientific, .correct: "1.729e-39" }, |
185 | {.value: 1.729e-38f, .fmt: chars_format::scientific, .correct: "1.729e-38" }, |
186 | {.value: 1.729e-37f, .fmt: chars_format::scientific, .correct: "1.729e-37" }, |
187 | {.value: 1.729e-36f, .fmt: chars_format::scientific, .correct: "1.729e-36" }, |
188 | {.value: 1.729e-35f, .fmt: chars_format::scientific, .correct: "1.729e-35" }, |
189 | {.value: 1.729e-34f, .fmt: chars_format::scientific, .correct: "1.729e-34" }, |
190 | {.value: 1.729e-33f, .fmt: chars_format::scientific, .correct: "1.729e-33" }, |
191 | {.value: 1.729e-32f, .fmt: chars_format::scientific, .correct: "1.729e-32" }, |
192 | {.value: 1.729e-31f, .fmt: chars_format::scientific, .correct: "1.729e-31" }, |
193 | {.value: 1.729e-30f, .fmt: chars_format::scientific, .correct: "1.729e-30" }, |
194 | {.value: 1.729e-29f, .fmt: chars_format::scientific, .correct: "1.729e-29" }, |
195 | {.value: 1.729e-28f, .fmt: chars_format::scientific, .correct: "1.729e-28" }, |
196 | {.value: 1.729e-27f, .fmt: chars_format::scientific, .correct: "1.729e-27" }, |
197 | {.value: 1.729e-26f, .fmt: chars_format::scientific, .correct: "1.729e-26" }, |
198 | {.value: 1.729e-25f, .fmt: chars_format::scientific, .correct: "1.729e-25" }, |
199 | {.value: 1.729e-24f, .fmt: chars_format::scientific, .correct: "1.729e-24" }, |
200 | {.value: 1.729e-23f, .fmt: chars_format::scientific, .correct: "1.729e-23" }, |
201 | {.value: 1.729e-22f, .fmt: chars_format::scientific, .correct: "1.729e-22" }, |
202 | {.value: 1.729e-21f, .fmt: chars_format::scientific, .correct: "1.729e-21" }, |
203 | {.value: 1.729e-20f, .fmt: chars_format::scientific, .correct: "1.729e-20" }, |
204 | {.value: 1.729e-19f, .fmt: chars_format::scientific, .correct: "1.729e-19" }, |
205 | {.value: 1.729e-18f, .fmt: chars_format::scientific, .correct: "1.729e-18" }, |
206 | {.value: 1.729e-17f, .fmt: chars_format::scientific, .correct: "1.729e-17" }, |
207 | {.value: 1.729e-16f, .fmt: chars_format::scientific, .correct: "1.729e-16" }, |
208 | {.value: 1.729e-15f, .fmt: chars_format::scientific, .correct: "1.729e-15" }, |
209 | {.value: 1.729e-14f, .fmt: chars_format::scientific, .correct: "1.729e-14" }, |
210 | {.value: 1.729e-13f, .fmt: chars_format::scientific, .correct: "1.729e-13" }, |
211 | {.value: 1.729e-12f, .fmt: chars_format::scientific, .correct: "1.729e-12" }, |
212 | {.value: 1.729e-11f, .fmt: chars_format::scientific, .correct: "1.729e-11" }, |
213 | {.value: 1.729e-10f, .fmt: chars_format::scientific, .correct: "1.729e-10" }, |
214 | {.value: 1.729e-9f, .fmt: chars_format::scientific, .correct: "1.729e-09" }, |
215 | {.value: 1.729e-8f, .fmt: chars_format::scientific, .correct: "1.729e-08" }, |
216 | {.value: 1.729e-7f, .fmt: chars_format::scientific, .correct: "1.729e-07" }, |
217 | {.value: 1.729e-6f, .fmt: chars_format::scientific, .correct: "1.729e-06" }, |
218 | {.value: 1.729e-5f, .fmt: chars_format::scientific, .correct: "1.729e-05" }, |
219 | {.value: 1.729e-4f, .fmt: chars_format::scientific, .correct: "1.729e-04" }, |
220 | {.value: 1.729e-3f, .fmt: chars_format::scientific, .correct: "1.729e-03" }, |
221 | {.value: 1.729e-2f, .fmt: chars_format::scientific, .correct: "1.729e-02" }, |
222 | {.value: 1.729e-1f, .fmt: chars_format::scientific, .correct: "1.729e-01" }, |
223 | {.value: 1.729e0f, .fmt: chars_format::scientific, .correct: "1.729e+00" }, |
224 | {.value: 1.729e1f, .fmt: chars_format::scientific, .correct: "1.729e+01" }, |
225 | {.value: 1.729e2f, .fmt: chars_format::scientific, .correct: "1.729e+02" }, |
226 | {.value: 1.729e3f, .fmt: chars_format::scientific, .correct: "1.729e+03" }, |
227 | {.value: 1.729e4f, .fmt: chars_format::scientific, .correct: "1.729e+04" }, |
228 | {.value: 1.729e5f, .fmt: chars_format::scientific, .correct: "1.729e+05" }, |
229 | {.value: 1.729e6f, .fmt: chars_format::scientific, .correct: "1.729e+06" }, |
230 | {.value: 1.729e7f, .fmt: chars_format::scientific, .correct: "1.729e+07" }, |
231 | {.value: 1.729e8f, .fmt: chars_format::scientific, .correct: "1.729e+08" }, |
232 | {.value: 1.729e9f, .fmt: chars_format::scientific, .correct: "1.729e+09" }, |
233 | {.value: 1.729e10f, .fmt: chars_format::scientific, .correct: "1.729e+10" }, |
234 | {.value: 1.729e11f, .fmt: chars_format::scientific, .correct: "1.729e+11" }, |
235 | {.value: 1.729e12f, .fmt: chars_format::scientific, .correct: "1.729e+12" }, |
236 | {.value: 1.729e13f, .fmt: chars_format::scientific, .correct: "1.729e+13" }, |
237 | {.value: 1.729e14f, .fmt: chars_format::scientific, .correct: "1.729e+14" }, |
238 | {.value: 1.729e15f, .fmt: chars_format::scientific, .correct: "1.729e+15" }, |
239 | {.value: 1.729e16f, .fmt: chars_format::scientific, .correct: "1.729e+16" }, |
240 | {.value: 1.729e17f, .fmt: chars_format::scientific, .correct: "1.729e+17" }, |
241 | {.value: 1.729e18f, .fmt: chars_format::scientific, .correct: "1.729e+18" }, |
242 | {.value: 1.729e19f, .fmt: chars_format::scientific, .correct: "1.729e+19" }, |
243 | {.value: 1.729e20f, .fmt: chars_format::scientific, .correct: "1.729e+20" }, |
244 | {.value: 1.729e21f, .fmt: chars_format::scientific, .correct: "1.729e+21" }, |
245 | {.value: 1.729e22f, .fmt: chars_format::scientific, .correct: "1.729e+22" }, |
246 | {.value: 1.729e23f, .fmt: chars_format::scientific, .correct: "1.729e+23" }, |
247 | {.value: 1.729e24f, .fmt: chars_format::scientific, .correct: "1.729e+24" }, |
248 | {.value: 1.729e25f, .fmt: chars_format::scientific, .correct: "1.729e+25" }, |
249 | {.value: 1.729e26f, .fmt: chars_format::scientific, .correct: "1.729e+26" }, |
250 | {.value: 1.729e27f, .fmt: chars_format::scientific, .correct: "1.729e+27" }, |
251 | {.value: 1.729e28f, .fmt: chars_format::scientific, .correct: "1.729e+28" }, |
252 | {.value: 1.729e29f, .fmt: chars_format::scientific, .correct: "1.729e+29" }, |
253 | {.value: 1.729e30f, .fmt: chars_format::scientific, .correct: "1.729e+30" }, |
254 | {.value: 1.729e31f, .fmt: chars_format::scientific, .correct: "1.729e+31" }, |
255 | {.value: 1.729e32f, .fmt: chars_format::scientific, .correct: "1.729e+32" }, |
256 | {.value: 1.729e33f, .fmt: chars_format::scientific, .correct: "1.729e+33" }, |
257 | {.value: 1.729e34f, .fmt: chars_format::scientific, .correct: "1.729e+34" }, |
258 | {.value: 1.729e35f, .fmt: chars_format::scientific, .correct: "1.729e+35" }, |
259 | {.value: 1.729e36f, .fmt: chars_format::scientific, .correct: "1.729e+36" }, |
260 | {.value: 1.729e37f, .fmt: chars_format::scientific, .correct: "1.729e+37" }, |
261 | {.value: 1.729e38f, .fmt: chars_format::scientific, .correct: "1.729e+38" }, |
262 | |
263 | // Test all of the cases for fixed notation, including the non-Ryu fallback for large integers. |
264 | {.value: 1.729e-4f, .fmt: chars_format::fixed, .correct: "0.0001729" }, |
265 | {.value: 1.729e-3f, .fmt: chars_format::fixed, .correct: "0.001729" }, |
266 | {.value: 1.729e-2f, .fmt: chars_format::fixed, .correct: "0.01729" }, |
267 | {.value: 1.729e-1f, .fmt: chars_format::fixed, .correct: "0.1729" }, |
268 | {.value: 1.729e0f, .fmt: chars_format::fixed, .correct: "1.729" }, |
269 | {.value: 1.729e1f, .fmt: chars_format::fixed, .correct: "17.29" }, |
270 | {.value: 1.729e2f, .fmt: chars_format::fixed, .correct: "172.9" }, |
271 | {.value: 1.729e3f, .fmt: chars_format::fixed, .correct: "1729" }, |
272 | {.value: 1.729e4f, .fmt: chars_format::fixed, .correct: "17290" }, |
273 | {.value: 1.729e5f, .fmt: chars_format::fixed, .correct: "172900" }, |
274 | {.value: 1.729e6f, .fmt: chars_format::fixed, .correct: "1729000" }, |
275 | {.value: 1.729e7f, .fmt: chars_format::fixed, .correct: "17290000" }, |
276 | {.value: 1.729e8f, .fmt: chars_format::fixed, .correct: "172900000" }, |
277 | {.value: 1.729e9f, .fmt: chars_format::fixed, .correct: "1728999936" }, |
278 | {.value: 1.729e10f, .fmt: chars_format::fixed, .correct: "17290000384" }, |
279 | {.value: 1.729e11f, .fmt: chars_format::fixed, .correct: "172900007936" }, |
280 | {.value: 1.729e12f, .fmt: chars_format::fixed, .correct: "1728999981056" }, |
281 | {.value: 1.729e13f, .fmt: chars_format::fixed, .correct: "17290000072704" }, |
282 | {.value: 1.729e14f, .fmt: chars_format::fixed, .correct: "172899998629888" }, |
283 | {.value: 1.729e15f, .fmt: chars_format::fixed, .correct: "1729000019853312" }, |
284 | {.value: 1.729e16f, .fmt: chars_format::fixed, .correct: "17289999661662208" }, |
285 | {.value: 1.729e17f, .fmt: chars_format::fixed, .correct: "172900007354040320" }, |
286 | {.value: 1.729e18f, .fmt: chars_format::fixed, .correct: "1729000039180664832" }, |
287 | {.value: 1.729e19f, .fmt: chars_format::fixed, .correct: "17289999567172927488" }, |
288 | {.value: 1.729e20f, .fmt: chars_format::fixed, .correct: "172899997870752530432" }, |
289 | {.value: 1.729e21f, .fmt: chars_format::fixed, .correct: "1729000013891897393152" }, |
290 | {.value: 1.729e22f, .fmt: chars_format::fixed, .correct: "17290000138918973931520" }, |
291 | {.value: 1.729e23f, .fmt: chars_format::fixed, .correct: "172899999137389925629952" }, |
292 | {.value: 1.729e24f, .fmt: chars_format::fixed, .correct: "1729000063431493294227456" }, |
293 | {.value: 1.729e25f, .fmt: chars_format::fixed, .correct: "17289999481393428335427584" }, |
294 | {.value: 1.729e26f, .fmt: chars_format::fixed, .correct: "172900004037306320209051648" }, |
295 | {.value: 1.729e27f, .fmt: chars_format::fixed, .correct: "1729000040373063202090516480" }, |
296 | {.value: 1.729e28f, .fmt: chars_format::fixed, .correct: "17290000403730632020905164800" }, |
297 | {.value: 1.729e29f, .fmt: chars_format::fixed, .correct: "172900004037306320209051648000" }, |
298 | {.value: 1.729e30f, .fmt: chars_format::fixed, .correct: "1728999964815199476176193060864" }, |
299 | {.value: 1.729e31f, .fmt: chars_format::fixed, .correct: "17290000252614904569076517961728" }, |
300 | {.value: 1.729e32f, .fmt: chars_format::fixed, .correct: "172899990436890849544473432555520" }, |
301 | {.value: 1.729e33f, .fmt: chars_format::fixed, .correct: "1729000059111413406117268687945728" }, |
302 | {.value: 1.729e34f, .fmt: chars_format::fixed, .correct: "17290000281629124239827618154676224" }, |
303 | {.value: 1.729e35f, .fmt: chars_format::fixed, .correct: "172899995388651006685994532152016896" }, |
304 | {.value: 1.729e36f, .fmt: chars_format::fixed, .correct: "1728999993500591323992114118292144128" }, |
305 | {.value: 1.729e37f, .fmt: chars_format::fixed, .correct: "17289999935005913239921141182921441280" }, |
306 | {.value: 1.729e38f, .fmt: chars_format::fixed, .correct: "172899996814757931942752608835808002048" }, |
307 | |
308 | // Also test one-digit cases, where the decimal point can't appear between digits like "17.29". |
309 | {.value: 7e-3f, .fmt: chars_format::fixed, .correct: "0.007" }, |
310 | {.value: 7e-2f, .fmt: chars_format::fixed, .correct: "0.07" }, |
311 | {.value: 7e-1f, .fmt: chars_format::fixed, .correct: "0.7" }, |
312 | {.value: 7e0f, .fmt: chars_format::fixed, .correct: "7" }, |
313 | {.value: 7e1f, .fmt: chars_format::fixed, .correct: "70" }, |
314 | {.value: 7e2f, .fmt: chars_format::fixed, .correct: "700" }, |
315 | {.value: 7e3f, .fmt: chars_format::fixed, .correct: "7000" }, |
316 | |
317 | // Test the maximum value in fixed notation. |
318 | {.value: 0x1.fffffep+127f, .fmt: chars_format::fixed, .correct: "340282346638528859811704183484516925440" }, |
319 | |
320 | // Test highly-trimmed powers of 2. |
321 | {.value: 0x1p118f, .fmt: chars_format::fixed, .correct: "332306998946228968225951765070086144" }, |
322 | {.value: 0x1p118f, .fmt: chars_format::scientific, .correct: "3.32307e+35" }, |
323 | {.value: 0x1p119f, .fmt: chars_format::fixed, .correct: "664613997892457936451903530140172288" }, |
324 | {.value: 0x1p119f, .fmt: chars_format::scientific, .correct: "6.64614e+35" }, |
325 | |
326 | // Test powers of 10 that are exactly representable. |
327 | {.value: 1e0f, .fmt: chars_format::fixed, .correct: "1" }, |
328 | {.value: 1e1f, .fmt: chars_format::fixed, .correct: "10" }, |
329 | {.value: 1e2f, .fmt: chars_format::fixed, .correct: "100" }, |
330 | {.value: 1e3f, .fmt: chars_format::fixed, .correct: "1000" }, |
331 | {.value: 1e4f, .fmt: chars_format::fixed, .correct: "10000" }, |
332 | {.value: 1e5f, .fmt: chars_format::fixed, .correct: "100000" }, |
333 | {.value: 1e6f, .fmt: chars_format::fixed, .correct: "1000000" }, |
334 | {.value: 1e7f, .fmt: chars_format::fixed, .correct: "10000000" }, |
335 | {.value: 1e8f, .fmt: chars_format::fixed, .correct: "100000000" }, |
336 | {.value: 1e9f, .fmt: chars_format::fixed, .correct: "1000000000" }, |
337 | {.value: 1e10f, .fmt: chars_format::fixed, .correct: "10000000000" }, |
338 | |
339 | // Test powers of 10 that aren't exactly representable. |
340 | // This exercises the "adjustment" code. |
341 | {.value: 1e11f, .fmt: chars_format::fixed, .correct: "99999997952" }, |
342 | {.value: 1e12f, .fmt: chars_format::fixed, .correct: "999999995904" }, |
343 | {.value: 1e13f, .fmt: chars_format::fixed, .correct: "9999999827968" }, |
344 | {.value: 1e14f, .fmt: chars_format::fixed, .correct: "100000000376832" }, |
345 | {.value: 1e15f, .fmt: chars_format::fixed, .correct: "999999986991104" }, |
346 | {.value: 1e16f, .fmt: chars_format::fixed, .correct: "10000000272564224" }, |
347 | {.value: 1e17f, .fmt: chars_format::fixed, .correct: "99999998430674944" }, |
348 | {.value: 1e18f, .fmt: chars_format::fixed, .correct: "999999984306749440" }, |
349 | {.value: 1e19f, .fmt: chars_format::fixed, .correct: "9999999980506447872" }, |
350 | {.value: 1e20f, .fmt: chars_format::fixed, .correct: "100000002004087734272" }, |
351 | {.value: 1e21f, .fmt: chars_format::fixed, .correct: "1000000020040877342720" }, |
352 | {.value: 1e22f, .fmt: chars_format::fixed, .correct: "9999999778196308361216" }, |
353 | {.value: 1e23f, .fmt: chars_format::fixed, .correct: "99999997781963083612160" }, |
354 | {.value: 1e24f, .fmt: chars_format::fixed, .correct: "1000000013848427855085568" }, |
355 | {.value: 1e25f, .fmt: chars_format::fixed, .correct: "9999999562023526247432192" }, |
356 | {.value: 1e26f, .fmt: chars_format::fixed, .correct: "100000002537764290115403776" }, |
357 | {.value: 1e27f, .fmt: chars_format::fixed, .correct: "999999988484154753734934528" }, |
358 | {.value: 1e28f, .fmt: chars_format::fixed, .correct: "9999999442119689768320106496" }, |
359 | {.value: 1e29f, .fmt: chars_format::fixed, .correct: "100000001504746621987668885504" }, |
360 | {.value: 1e30f, .fmt: chars_format::fixed, .correct: "1000000015047466219876688855040" }, |
361 | {.value: 1e31f, .fmt: chars_format::fixed, .correct: "9999999848243207295109594873856" }, |
362 | {.value: 1e32f, .fmt: chars_format::fixed, .correct: "100000003318135351409612647563264" }, |
363 | {.value: 1e33f, .fmt: chars_format::fixed, .correct: "999999994495727286427992885035008" }, |
364 | {.value: 1e34f, .fmt: chars_format::fixed, .correct: "9999999790214767953607394487959552" }, |
365 | {.value: 1e35f, .fmt: chars_format::fixed, .correct: "100000004091847875962975319375216640" }, |
366 | {.value: 1e36f, .fmt: chars_format::fixed, .correct: "999999961690316245365415600208216064" }, |
367 | {.value: 1e37f, .fmt: chars_format::fixed, .correct: "9999999933815812510711506376257961984" }, |
368 | {.value: 1e38f, .fmt: chars_format::fixed, .correct: "99999996802856924650656260769173209088" }, |
369 | |
370 | // These numbers have odd mantissas (unaffected by shifting) |
371 | // that are barely within the "max shifted mantissa" limit. |
372 | // They're exactly-representable multiples of powers of 10, and can use Ryu with zero-filling. |
373 | {.value: 3355443e1f, .fmt: chars_format::fixed, .correct: "33554430" }, |
374 | {.value: 671087e2f, .fmt: chars_format::fixed, .correct: "67108700" }, |
375 | {.value: 134217e3f, .fmt: chars_format::fixed, .correct: "134217000" }, |
376 | {.value: 26843e4f, .fmt: chars_format::fixed, .correct: "268430000" }, |
377 | {.value: 5367e5f, .fmt: chars_format::fixed, .correct: "536700000" }, |
378 | {.value: 1073e6f, .fmt: chars_format::fixed, .correct: "1073000000" }, |
379 | {.value: 213e7f, .fmt: chars_format::fixed, .correct: "2130000000" }, |
380 | {.value: 41e8f, .fmt: chars_format::fixed, .correct: "4100000000" }, |
381 | {.value: 7e9f, .fmt: chars_format::fixed, .correct: "7000000000" }, |
382 | {.value: 1e10f, .fmt: chars_format::fixed, .correct: "10000000000" }, |
383 | |
384 | // These numbers have odd mantissas (unaffected by shifting) |
385 | // that are barely above the "max shifted mantissa" limit. |
386 | // This activates the non-Ryu fallback for large integers. |
387 | {.value: 3355445e1f, .fmt: chars_format::fixed, .correct: "33554448" }, |
388 | {.value: 671089e2f, .fmt: chars_format::fixed, .correct: "67108896" }, |
389 | {.value: 134219e3f, .fmt: chars_format::fixed, .correct: "134219008" }, |
390 | {.value: 26845e4f, .fmt: chars_format::fixed, .correct: "268449984" }, |
391 | {.value: 5369e5f, .fmt: chars_format::fixed, .correct: "536899968" }, |
392 | {.value: 1075e6f, .fmt: chars_format::fixed, .correct: "1075000064" }, |
393 | {.value: 215e7f, .fmt: chars_format::fixed, .correct: "2150000128" }, |
394 | {.value: 43e8f, .fmt: chars_format::fixed, .correct: "4300000256" }, |
395 | {.value: 9e9f, .fmt: chars_format::fixed, .correct: "8999999488" }, |
396 | {.value: 3e10f, .fmt: chars_format::fixed, .correct: "30000001024" }, |
397 | |
398 | // Test the mantissa shifting logic. |
399 | {.value: 5495808e5f, .fmt: chars_format::fixed, .correct: "549580800000" }, // 5367 * 2^10 |
400 | {.value: 5497856e5f, .fmt: chars_format::fixed, .correct: "549785567232" }, // 5369 * 2^10 |
401 | |
402 | // Inspect all of those numbers in scientific notation. |
403 | // For the within-limit numbers, this verifies that Ryu is actually being used with zero-filling above. |
404 | // For the above-limit numbers, this tests Ryu's trimming. |
405 | {.value: 3355443e1f, .fmt: chars_format::scientific, .correct: "3.355443e+07" }, |
406 | {.value: 671087e2f, .fmt: chars_format::scientific, .correct: "6.71087e+07" }, |
407 | {.value: 134217e3f, .fmt: chars_format::scientific, .correct: "1.34217e+08" }, |
408 | {.value: 26843e4f, .fmt: chars_format::scientific, .correct: "2.6843e+08" }, |
409 | {.value: 5367e5f, .fmt: chars_format::scientific, .correct: "5.367e+08" }, |
410 | {.value: 1073e6f, .fmt: chars_format::scientific, .correct: "1.073e+09" }, |
411 | {.value: 213e7f, .fmt: chars_format::scientific, .correct: "2.13e+09" }, |
412 | {.value: 41e8f, .fmt: chars_format::scientific, .correct: "4.1e+09" }, |
413 | {.value: 7e9f, .fmt: chars_format::scientific, .correct: "7e+09" }, |
414 | {.value: 1e10f, .fmt: chars_format::scientific, .correct: "1e+10" }, |
415 | {.value: 3355445e1f, .fmt: chars_format::scientific, .correct: "3.355445e+07" }, |
416 | {.value: 671089e2f, .fmt: chars_format::scientific, .correct: "6.71089e+07" }, |
417 | {.value: 134219e3f, .fmt: chars_format::scientific, .correct: "1.34219e+08" }, |
418 | {.value: 26845e4f, .fmt: chars_format::scientific, .correct: "2.6845e+08" }, |
419 | {.value: 5369e5f, .fmt: chars_format::scientific, .correct: "5.369e+08" }, |
420 | {.value: 1075e6f, .fmt: chars_format::scientific, .correct: "1.075e+09" }, |
421 | {.value: 215e7f, .fmt: chars_format::scientific, .correct: "2.15e+09" }, |
422 | {.value: 43e8f, .fmt: chars_format::scientific, .correct: "4.3e+09" }, |
423 | {.value: 9e9f, .fmt: chars_format::scientific, .correct: "9e+09" }, |
424 | {.value: 3e10f, .fmt: chars_format::scientific, .correct: "3e+10" }, |
425 | {.value: 5495808e5f, .fmt: chars_format::scientific, .correct: "5.495808e+11" }, |
426 | {.value: 5497856e5f, .fmt: chars_format::scientific, .correct: "5.497856e+11" }, |
427 | |
428 | // Test the switching logic of chars_format::general. |
429 | // C11 7.21.6.1 "The fprintf function"/8: |
430 | // "Let P equal [...] 6 if the precision is omitted [...]. |
431 | // Then, if a conversion with style E would have an exponent of X: |
432 | // - if P > X >= -4, the conversion is with style f [...]. |
433 | // - otherwise, the conversion is with style e [...]." |
434 | {.value: 1e-6f, .fmt: chars_format::general, .correct: "1e-06" }, |
435 | {.value: 1e-5f, .fmt: chars_format::general, .correct: "1e-05" }, |
436 | {.value: 1e-4f, .fmt: chars_format::general, .correct: "0.0001" }, |
437 | {.value: 1e-3f, .fmt: chars_format::general, .correct: "0.001" }, |
438 | {.value: 1e-2f, .fmt: chars_format::general, .correct: "0.01" }, |
439 | {.value: 1e-1f, .fmt: chars_format::general, .correct: "0.1" }, |
440 | {.value: 1e0f, .fmt: chars_format::general, .correct: "1" }, |
441 | {.value: 1e1f, .fmt: chars_format::general, .correct: "10" }, |
442 | {.value: 1e2f, .fmt: chars_format::general, .correct: "100" }, |
443 | {.value: 1e3f, .fmt: chars_format::general, .correct: "1000" }, |
444 | {.value: 1e4f, .fmt: chars_format::general, .correct: "10000" }, |
445 | {.value: 1e5f, .fmt: chars_format::general, .correct: "100000" }, |
446 | {.value: 1e6f, .fmt: chars_format::general, .correct: "1e+06" }, |
447 | {.value: 1e7f, .fmt: chars_format::general, .correct: "1e+07" }, |
448 | {.value: 1.234e-6f, .fmt: chars_format::general, .correct: "1.234e-06" }, |
449 | {.value: 1.234e-5f, .fmt: chars_format::general, .correct: "1.234e-05" }, |
450 | {.value: 1.234e-4f, .fmt: chars_format::general, .correct: "0.0001234" }, |
451 | {.value: 1.234e-3f, .fmt: chars_format::general, .correct: "0.001234" }, |
452 | {.value: 1.234e-2f, .fmt: chars_format::general, .correct: "0.01234" }, |
453 | {.value: 1.234e-1f, .fmt: chars_format::general, .correct: "0.1234" }, |
454 | {.value: 1.234e0f, .fmt: chars_format::general, .correct: "1.234" }, |
455 | {.value: 1.234e1f, .fmt: chars_format::general, .correct: "12.34" }, |
456 | {.value: 1.234e2f, .fmt: chars_format::general, .correct: "123.4" }, |
457 | {.value: 1.234e3f, .fmt: chars_format::general, .correct: "1234" }, |
458 | {.value: 1.234e4f, .fmt: chars_format::general, .correct: "12340" }, |
459 | {.value: 1.234e5f, .fmt: chars_format::general, .correct: "123400" }, |
460 | {.value: 1.234e6f, .fmt: chars_format::general, .correct: "1.234e+06" }, |
461 | {.value: 1.234e7f, .fmt: chars_format::general, .correct: "1.234e+07" }, |
462 | {.value: 1.234e8f, .fmt: chars_format::general, .correct: "1.234e+08" }, |
463 | {.value: 1.234e9f, .fmt: chars_format::general, .correct: "1.234e+09" }, |
464 | {.value: 1.234e10f, .fmt: chars_format::general, .correct: "1.234e+10" }, |
465 | |
466 | // Test the switching logic of the plain overload. |
467 | // N4762 19.19.2 [charconv.to.chars]/8: |
468 | // "The conversion specifier is f or e, chosen according to the requirement |
469 | // for a shortest representation (see above); a tie is resolved in favor of f." |
470 | {.value: 1e-6f, .fmt: chars_format{}, .correct: "1e-06" }, |
471 | {.value: 1e-5f, .fmt: chars_format{}, .correct: "1e-05" }, |
472 | {.value: 1e-4f, .fmt: chars_format{}, .correct: "1e-04" }, |
473 | {.value: 1e-3f, .fmt: chars_format{}, .correct: "0.001" }, |
474 | {.value: 1e-2f, .fmt: chars_format{}, .correct: "0.01" }, |
475 | {.value: 1e-1f, .fmt: chars_format{}, .correct: "0.1" }, |
476 | {.value: 1e0f, .fmt: chars_format{}, .correct: "1" }, |
477 | {.value: 1e1f, .fmt: chars_format{}, .correct: "10" }, |
478 | {.value: 1e2f, .fmt: chars_format{}, .correct: "100" }, |
479 | {.value: 1e3f, .fmt: chars_format{}, .correct: "1000" }, |
480 | {.value: 1e4f, .fmt: chars_format{}, .correct: "10000" }, |
481 | {.value: 1e5f, .fmt: chars_format{}, .correct: "1e+05" }, |
482 | {.value: 1e6f, .fmt: chars_format{}, .correct: "1e+06" }, |
483 | {.value: 1e7f, .fmt: chars_format{}, .correct: "1e+07" }, |
484 | {.value: 1.234e-6f, .fmt: chars_format{}, .correct: "1.234e-06" }, |
485 | {.value: 1.234e-5f, .fmt: chars_format{}, .correct: "1.234e-05" }, |
486 | {.value: 1.234e-4f, .fmt: chars_format{}, .correct: "0.0001234" }, |
487 | {.value: 1.234e-3f, .fmt: chars_format{}, .correct: "0.001234" }, |
488 | {.value: 1.234e-2f, .fmt: chars_format{}, .correct: "0.01234" }, |
489 | {.value: 1.234e-1f, .fmt: chars_format{}, .correct: "0.1234" }, |
490 | {.value: 1.234e0f, .fmt: chars_format{}, .correct: "1.234" }, |
491 | {.value: 1.234e1f, .fmt: chars_format{}, .correct: "12.34" }, |
492 | {.value: 1.234e2f, .fmt: chars_format{}, .correct: "123.4" }, |
493 | {.value: 1.234e3f, .fmt: chars_format{}, .correct: "1234" }, |
494 | {.value: 1.234e4f, .fmt: chars_format{}, .correct: "12340" }, |
495 | {.value: 1.234e5f, .fmt: chars_format{}, .correct: "123400" }, |
496 | {.value: 1.234e6f, .fmt: chars_format{}, .correct: "1234000" }, |
497 | {.value: 1.234e7f, .fmt: chars_format{}, .correct: "12340000" }, |
498 | {.value: 1.234e8f, .fmt: chars_format{}, .correct: "123400000" }, |
499 | {.value: 1.234e9f, .fmt: chars_format{}, .correct: "1.234e+09" }, |
500 | {.value: 1.234e10f, .fmt: chars_format{}, .correct: "1.234e+10" }, |
501 | |
502 | // Test hexfloat corner cases. |
503 | {.value: 0x1.728p+0f, .fmt: chars_format::hex, .correct: "1.728p+0" }, // instead of "2.e5p-1" |
504 | {.value: 0x0.000002p-126f, .fmt: chars_format::hex, .correct: "0.000002p-126" }, // instead of "1p-149", min subnormal |
505 | {.value: 0x0.fffffep-126f, .fmt: chars_format::hex, .correct: "0.fffffep-126" }, // max subnormal |
506 | {.value: 0x1p-126f, .fmt: chars_format::hex, .correct: "1p-126" }, // min normal |
507 | {.value: 0x1.fffffep+127f, .fmt: chars_format::hex, .correct: "1.fffffep+127" }, // max normal |
508 | |
509 | // Test hexfloat exponents. |
510 | {.value: 0x1p-109f, .fmt: chars_format::hex, .correct: "1p-109" }, |
511 | {.value: 0x1p-99f, .fmt: chars_format::hex, .correct: "1p-99" }, |
512 | {.value: 0x1p-9f, .fmt: chars_format::hex, .correct: "1p-9" }, |
513 | {.value: 0x1p+0f, .fmt: chars_format::hex, .correct: "1p+0" }, |
514 | {.value: 0x1p+9f, .fmt: chars_format::hex, .correct: "1p+9" }, |
515 | {.value: 0x1p+99f, .fmt: chars_format::hex, .correct: "1p+99" }, |
516 | {.value: 0x1p+109f, .fmt: chars_format::hex, .correct: "1p+109" }, |
517 | |
518 | // Test hexfloat hexits. |
519 | {.value: 0x1.0123p+0f, .fmt: chars_format::hex, .correct: "1.0123p+0" }, |
520 | {.value: 0x1.4567p+0f, .fmt: chars_format::hex, .correct: "1.4567p+0" }, |
521 | {.value: 0x1.89abp+0f, .fmt: chars_format::hex, .correct: "1.89abp+0" }, |
522 | {.value: 0x1.cdefp+0f, .fmt: chars_format::hex, .correct: "1.cdefp+0" }, |
523 | |
524 | // Test hexfloat trimming. |
525 | {.value: 0x1.00000ap+0f, .fmt: chars_format::hex, .correct: "1.00000ap+0" }, |
526 | {.value: 0x1.0000ap+0f, .fmt: chars_format::hex, .correct: "1.0000ap+0" }, |
527 | {.value: 0x1.000ap+0f, .fmt: chars_format::hex, .correct: "1.000ap+0" }, |
528 | {.value: 0x1.00ap+0f, .fmt: chars_format::hex, .correct: "1.00ap+0" }, |
529 | {.value: 0x1.0ap+0f, .fmt: chars_format::hex, .correct: "1.0ap+0" }, |
530 | {.value: 0x1.ap+0f, .fmt: chars_format::hex, .correct: "1.ap+0" }, |
531 | {.value: 0x1p+0f, .fmt: chars_format::hex, .correct: "1p+0" }, |
532 | |
533 | // https://www.exploringbinary.com/the-shortest-decimal-string-that-round-trips-may-not-be-the-nearest/ |
534 | // This is an exhaustive list of anomalous values. |
535 | // (See double_to_chars_test_cases.hpp for more details.) |
536 | {.value: 0x1p90f, .fmt: chars_format::scientific, .correct: "1.2379401e+27" }, |
537 | {.value: 0x1p87f, .fmt: chars_format::scientific, .correct: "1.5474251e+26" }, |
538 | {.value: 0x1p-96f, .fmt: chars_format::scientific, .correct: "1.2621775e-29" }, |
539 | }; |
540 | |
541 | #endif // FLOAT_TO_CHARS_TEST_CASES_HPP |
542 | |