OLD | NEW |
1 /*********************************************************************** | 1 /*********************************************************************** |
2 * COPYRIGHT: | 2 * COPYRIGHT: |
3 * Copyright (c) 1997-2010, International Business Machines Corporation | 3 * Copyright (c) 1997-2010, International Business Machines Corporation |
4 * and others. All Rights Reserved. | 4 * and others. All Rights Reserved. |
5 ***********************************************************************/ | 5 ***********************************************************************/ |
6 | 6 |
7 #include "unicode/utypes.h" | 7 #include "unicode/utypes.h" |
8 | 8 |
9 #if !UCONFIG_NO_FORMATTING | 9 #if !UCONFIG_NO_FORMATTING |
10 | 10 |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
175 // {sfb} When formatting with a percent instance, numbers very close to | 175 // {sfb} When formatting with a percent instance, numbers very close to |
176 // DBL_MAX will fail the round trip. This is because: | 176 // DBL_MAX will fail the round trip. This is because: |
177 // 1) Format the double into a string --> INF% (since 100 * double > DBL
_MAX) | 177 // 1) Format the double into a string --> INF% (since 100 * double > DBL
_MAX) |
178 // 2) Parse the string into a double --> INF | 178 // 2) Parse the string into a double --> INF |
179 // 3) Re-format the double --> INF% | 179 // 3) Re-format the double --> INF% |
180 // 4) The strings are equal, so that works. | 180 // 4) The strings are equal, so that works. |
181 // 5) Calculate the proportional error --> INF, so the test will fail | 181 // 5) Calculate the proportional error --> INF, so the test will fail |
182 // I'll get around this by dividing by the multiplier to make sure | 182 // I'll get around this by dividing by the multiplier to make sure |
183 // the double will stay in range. | 183 // the double will stay in range. |
184 //if(fmt->getMultipler() == 1) | 184 //if(fmt->getMultipler() == 1) |
185 DecimalFormat *df = dynamic_cast<DecimalFormat *>(fmt); | 185 DecimalFormat *df = CR_DYNAMIC_CAST<DecimalFormat *>(fmt); |
186 if(df != NULL) | 186 if(df != NULL) |
187 { | 187 { |
188 #if !defined(OS390) && !defined(OS400) | 188 #if !defined(OS390) && !defined(OS400) |
189 /* DBL_MAX/2 is here because randomDouble does a *2 in the math */ | 189 /* DBL_MAX/2 is here because randomDouble does a *2 in the math */ |
190 test(fmt, randomDouble(DBL_MAX/2.0) / df->getMultiplier()); | 190 test(fmt, randomDouble(DBL_MAX/2.0) / df->getMultiplier()); |
191 #elif IEEE_754 | 191 #elif IEEE_754 |
192 test(fmt, randomDouble(1e75) / df->getMultiplier()); | 192 test(fmt, randomDouble(1e75) / df->getMultiplier()); |
193 #else | 193 #else |
194 test(fmt, randomDouble(1e65) / df->getMultiplier()); /*OS390*/ | 194 test(fmt, randomDouble(1e65) / df->getMultiplier()); /*OS390*/ |
195 #endif | 195 #endif |
(...skipping 27 matching lines...) Expand all Loading... |
223 void | 223 void |
224 NumberFormatRoundTripTest::test(NumberFormat *fmt, int32_t value) | 224 NumberFormatRoundTripTest::test(NumberFormat *fmt, int32_t value) |
225 { | 225 { |
226 test(fmt, Formattable(value)); | 226 test(fmt, Formattable(value)); |
227 } | 227 } |
228 | 228 |
229 void | 229 void |
230 NumberFormatRoundTripTest::test(NumberFormat *fmt, const Formattable& value) | 230 NumberFormatRoundTripTest::test(NumberFormat *fmt, const Formattable& value) |
231 { | 231 { |
232 fmt->setMaximumFractionDigits(999); | 232 fmt->setMaximumFractionDigits(999); |
233 DecimalFormat *df = dynamic_cast<DecimalFormat *>(fmt); | 233 DecimalFormat *df = CR_DYNAMIC_CAST<DecimalFormat *>(fmt); |
234 if(df != NULL) { | 234 if(df != NULL) { |
235 df->setRoundingIncrement(0.0); | 235 df->setRoundingIncrement(0.0); |
236 } | 236 } |
237 UErrorCode status = U_ZERO_ERROR; | 237 UErrorCode status = U_ZERO_ERROR; |
238 UnicodeString s, s2, temp; | 238 UnicodeString s, s2, temp; |
239 if(isDouble(value)) | 239 if(isDouble(value)) |
240 s = fmt->format(value.getDouble(), s); | 240 s = fmt->format(value.getDouble(), s); |
241 else | 241 else |
242 s = fmt->format(value.getLong(), s); | 242 s = fmt->format(value.getLong(), s); |
243 | 243 |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 s += "+U"; | 348 s += "+U"; |
349 char temp[16]; | 349 char temp[16]; |
350 sprintf(temp, "%4X", c); // might not work | 350 sprintf(temp, "%4X", c); // might not work |
351 s += temp; | 351 s += temp; |
352 } | 352 } |
353 } | 353 } |
354 return s; | 354 return s; |
355 } | 355 } |
356 | 356 |
357 #endif /* #if !UCONFIG_NO_FORMATTING */ | 357 #endif /* #if !UCONFIG_NO_FORMATTING */ |
OLD | NEW |