Skip to content

Commit

Permalink
tg: fix warnings in tg.c
Browse files Browse the repository at this point in the history
* big_table is unsigned short, so cast (float * char * char)
* 1.0 is double, but tg_big_create expects float, so change constant to
  1.0f
* ascore:

	warning C4146: unary minus operator applied to unsigned type, result
	still unsigned

  so I changed it to -1 * ascore.
  • Loading branch information
bmateusz authored and masatake committed Feb 24, 2015
1 parent 1565d27 commit b68ed3c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tg.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ static unsigned short* tg_big_create (const unsigned char *a, const unsigned cha

/* TODO: Maybe sqrt is needed. */
for (i = 0; i < 255 * 255; i++)
big_table[i] = ratio * a[i] * b[i];
big_table[i] = (unsigned short)(ratio * a[i] * b[i]);

return big_table;
}
Expand Down Expand Up @@ -258,13 +258,13 @@ int tg_compare(const unsigned char *a, const unsigned char *b, const unsigned ch
else
max = bsz;

abt = tg_big_create(a, t, (1.0 * max) / (1.0 * asz));
bbt = tg_big_create(b, t, (1.0 * max) / (1.0 * bsz));
abt = tg_big_create(a, t, (1.0f * max) / (1.0f * asz));
bbt = tg_big_create(b, t, (1.0f * max) / (1.0f * bsz));
ascore = tg_big_score(abt);
bscore = tg_big_score(bbt);

if (ascore > bscore)
r = - ascore;
r = -1 * ascore;
else if (ascore < bscore)
r = bscore;
else
Expand Down

0 comments on commit b68ed3c

Please sign in to comment.