diff options
author | Grigori Goronzy <greg@blackbox> | 2009-07-08 00:25:05 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2009-07-08 00:25:05 +0200 |
commit | 55e9f91ec4868e8cd9098b367a0d935d703290d4 (patch) | |
tree | 6b2b2526ce4b27929f2f9a2345abb040f9249915 /libass | |
parent | 6302f307524b430992bd7d71036f7b46c702f678 (diff) | |
download | libass-55e9f91ec4868e8cd9098b367a0d935d703290d4.tar.bz2 libass-55e9f91ec4868e8cd9098b367a0d935d703290d4.tar.xz |
Correctly round doubles to integers
mystrtoi and mystrtoll did not round correctly for negative numbers,
this was fixed.
Diffstat (limited to 'libass')
-rw-r--r-- | libass/ass_utils.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libass/ass_utils.c b/libass/ass_utils.c index 16f868a2..5f632684 100644 --- a/libass/ass_utils.c +++ b/libass/ass_utils.c @@ -33,7 +33,7 @@ int mystrtoi(char **p, int *res) double temp_res; char *start = *p; temp_res = strtod(*p, p); - *res = (int) (temp_res + 0.5); + *res = (int) (temp_res + (temp_res > 0 ? 0.5 : -0.5)); if (*p != start) return 1; else @@ -45,7 +45,7 @@ int mystrtoll(char **p, long long *res) double temp_res; char *start = *p; temp_res = strtod(*p, p); - *res = (long long) (temp_res + 0.5); + *res = (int) (temp_res + (temp_res > 0 ? 0.5 : -0.5)); if (*p != start) return 1; else |