1
0
mirror of https://github.com/mariadb-corporation/mariadb-connector-c.git synced 2025-08-08 14:02:17 +03:00

compilation failure on windows

libmariadb\libmariadb\ma_stmt_codec.c(263): warning C4244: '*=': conversion from 'double' to 'unsigned long', possible loss of data

generally avoid slow floating point pow() when all you need is to
multiply an integer by a small power of 10.
This commit is contained in:
Sergei Golubchik
2018-11-07 07:45:23 +01:00
parent 41b988ddcf
commit efc9f60dbf
2 changed files with 5 additions and 2 deletions

View File

@@ -260,7 +260,10 @@ my_bool str_to_TIME(const char *str, size_t length, MYSQL_TIME *tm)
goto error;
/* conc-371 */
if (frac_len < 6)
tm->second_part*= pow(10, 6 - frac_len);
{
static ulong mul[]={1000000,100000,10000,1000,100,10};
tm->second_part*= mul[frac_len];
}
} else {
if (sscanf(start, "%d:%d:%d", &tm->hour, &tm->minute,
&tm->second) < 3)

View File

@@ -4821,7 +4821,7 @@ static int test_conc_fraction(MYSQL *mysql)
diag("second_part: %ld", tm.second_part);
expected= 9 * powl(10, (5 - i));
expected= 9 * (unsigned int)powl(10, (5 - i));
FAIL_IF(tm.second_part != expected, "expected fractional part to be 900000");