ICU-11439 Improve portability of DecimalFormat::getFixedDecimal().

X-SVN-Rev: 36894
This commit is contained in:
Andy Heninger 2014-12-19 00:22:05 +00:00
parent ff85125d2f
commit a1d3e7d662

View File

@ -29,6 +29,7 @@
#include <float.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include "cstring.h"
#include "unicode/numsys.h"
#include "fmtableimp.h"
@ -7752,22 +7753,22 @@ void NumberFormatTest::TestCurrencyUsage() {
void NumberFormatTest::TestDoubleLimit11439() {
char buf[50];
for (int64_t num = MAX_INT64_IN_DOUBLE-10; num<=MAX_INT64_IN_DOUBLE; num++) {
sprintf(buf, "%ld", num);
sprintf(buf, "%" PRId64, num);
double fNum = 0.0;
sscanf(buf, "%lf", &fNum);
int64_t rtNum = fNum;
if (num != rtNum) {
errln("%s:%d MAX_INT64_IN_DOUBLE test, %ld did not round trip. Got %ld", __FILE__, __LINE__, num, rtNum);
errln("%s:%d MAX_INT64_IN_DOUBLE test, %" PRId64 " did not round trip. Got %" PRId64 , __FILE__, __LINE__, num, rtNum);
return;
}
}
for (int64_t num = -MAX_INT64_IN_DOUBLE+10; num>=-MAX_INT64_IN_DOUBLE; num--) {
sprintf(buf, "%ld", num);
sprintf(buf, "%" PRId64, num);
double fNum = 0.0;
sscanf(buf, "%lf", &fNum);
int64_t rtNum = fNum;
if (num != rtNum) {
errln("%s:%d MAX_INT64_IN_DOUBLE test, %ld did not round trip. Got %ld", __FILE__, __LINE__, num, rtNum);
errln("%s:%d MAX_INT64_IN_DOUBLE test, %" PRId64 "did not round trip. Got %" PRId64 , __FILE__, __LINE__, num, rtNum);
return;
}
}