diff options
author | Bruce Momjian <bruce@momjian.us> | 2007-02-17 03:11:32 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2007-02-17 03:11:32 +0000 |
commit | 4fe1a12c54f31697dfc1ed09ad6716cefb4aa8bf (patch) | |
tree | 18c60cb1f57ba4fda871c25613a05680c0a619ac /src/backend/utils/adt/formatting.c | |
parent | 37a22932f2613172ee1dc784e6d0f8862fb6a3c2 (diff) | |
download | postgresql-4fe1a12c54f31697dfc1ed09ad6716cefb4aa8bf.tar.gz postgresql-4fe1a12c54f31697dfc1ed09ad6716cefb4aa8bf.zip |
Remove rint() for to_char MS and US output. We can't us rint() because
we can't overflow to the next higher units, and we might print the lower
units for MS.
Diffstat (limited to 'src/backend/utils/adt/formatting.c')
-rw-r--r-- | src/backend/utils/adt/formatting.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 0a746a0738c..344bf7db087 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.127 2007/02/17 01:51:42 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.128 2007/02/17 03:11:32 momjian Exp $ * * * Portions Copyright (c) 1999-2007, PostgreSQL Global Development Group @@ -2000,7 +2000,8 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, #ifdef HAVE_INT64_TIMESTAMP sprintf(inout, "%03d", (int) (tmtc->fsec / INT64CONST(1000))); #else - sprintf(inout, "%03d", (int) rint(tmtc->fsec * 1000)); + /* No rint() because we can't overflow and we might print US */ + sprintf(inout, "%03d", (int) (tmtc->fsec * 1000)); #endif if (S_THth(suf)) str_numth(p_inout, inout, S_TH_TYPE(suf)); @@ -2041,7 +2042,8 @@ dch_time(int arg, char *inout, int suf, bool is_to_char, bool is_interval, #ifdef HAVE_INT64_TIMESTAMP sprintf(inout, "%06d", (int) tmtc->fsec); #else - sprintf(inout, "%06d", (int) rint(tmtc->fsec * 1000000)); + /* don't use rint() because we can't overflow 1000 */ + sprintf(inout, "%06d", (int) (tmtc->fsec * 1000000)); #endif if (S_THth(suf)) str_numth(p_inout, inout, S_TH_TYPE(suf)); |