Fixed warnings

master
Christophe Riccio ago%!(EXTRA string=8 years)
parent 6c23545fbc
commit d799c282db
  1. 43
      test/core/core_func_integer_find_msb.cpp

@ -34,7 +34,7 @@ int nlz1a(unsigned x) {
int n;
/* if (x == 0) return(32); */
if ((int)x <= 0) return (~x >> 26) & 32;
if (static_cast<int>(x) <= 0) return (~x >> 26) & 32;
n = 1;
if ((x >> 16) == 0) {n = n +16; x = x <<16;}
if ((x >> 24) == 0) {n = n + 8; x = x << 8;}
@ -141,26 +141,28 @@ gcc/AIX, and gcc/NT, at some optimization levels.
BTW, these programs use the "anonymous union" feature of C++, not
available in C. */
int nlz6(unsigned k) {
int nlz6(unsigned k)
{
union {
unsigned asInt[2];
double asDouble;
};
int n;
asDouble = (double)k + 0.5;
asDouble = static_cast<double>(k) + 0.5;
n = 1054 - (asInt[LE] >> 20);
return n;
}
int nlz7(unsigned k) {
int nlz7(unsigned k)
{
union {
unsigned asInt[2];
double asDouble;
};
int n;
asDouble = (double)k;
asDouble = static_cast<double>(k);
n = 1054 - (asInt[LE] >> 20);
n = (n & 31) + (n >> 9);
return n;
@ -175,7 +177,8 @@ int nlz7(unsigned k) {
FFFFFF80 <= k <= FFFFFFFF.
For k = 0 it gives 158, and for the other values it is too low by 1. */
int nlz8(unsigned k) {
int nlz8(unsigned k)
{
union {
unsigned asInt;
float asFloat;
@ -183,7 +186,7 @@ int nlz8(unsigned k) {
int n;
k = k & ~(k >> 1); /* Fix problem with rounding. */
asFloat = (float)k + 0.5f;
asFloat = static_cast<float>(k) + 0.5f;
n = 158 - (asInt >> 23);
return n;
}
@ -196,7 +199,8 @@ expressions (see "Using and Porting GNU CC", by Richard M. Stallman
possibility that the macro argument will conflict with one of its local
variables, e.g., NLZ(k). */
int nlz9(unsigned k) {
int nlz9(unsigned k)
{
union {
unsigned asInt;
float asFloat;
@ -204,7 +208,7 @@ int nlz9(unsigned k) {
int n;
k = k & ~(k >> 1); /* Fix problem with rounding. */
asFloat = (float)k;
asFloat = static_cast<float>(k);
n = 158 - (asInt >> 23);
n = (n & 31) + (n >> 6); /* Fix problem with k = 0. */
return n;
@ -229,8 +233,8 @@ multiplication expanded into shifts and adds, but the table size is
getting a bit large). */
#define u 99
int nlz10(unsigned x) {
int nlz10(unsigned x)
{
static char table[64] =
{32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u,
u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u,
@ -249,8 +253,8 @@ int nlz10(unsigned x) {
/* Harley's algorithm with multiply expanded.
19 elementary ops plus an indexed load. */
int nlz10a(unsigned x) {
int nlz10a(unsigned x)
{
static char table[64] =
{32,31, u,16, u,30, 3, u, 15, u, u, u,29,10, 2, u,
u, u,12,14,21, u,19, u, u,28, u,25, u, 9, 1, u,
@ -273,8 +277,8 @@ int nlz10a(unsigned x) {
17 elementary ops plus an indexed load, if the machine
has "and not." */
int nlz10b(unsigned x) {
int nlz10b(unsigned x)
{
static char table[64] =
{32,20,19, u, u,18, u, 7, 10,17, u, u,14, u, 6, u,
u, 9, u,16, u, u, 1,26, u,13, u, u,24, 5, u, u,
@ -287,14 +291,15 @@ int nlz10b(unsigned x) {
x = x | (x >> 8);
x = x & ~(x >> 16);
x = x*0xFD7049FF; // Activate this line or the following 3.
// x = (x << 9) - x; // Multiply by 511.
// x = (x << 11) - x; // Multiply by 2047.
// x = (x << 14) - x; // Multiply by 16383.
// x = (x << 9) - x; // Multiply by 511.
// x = (x << 11) - x; // Multiply by 2047.
// x = (x << 14) - x; // Multiply by 16383.
return table[x >> 26];
}
int errors;
void error(int x, int y) {
void error(int x, int y)
{
errors = errors + 1;
printf("Error for x = %08x, got %d\n", x, y);
}

Loading…
Cancel
Save