summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc80
-rw-r--r--gr-error-correcting-codes/src/lib/libecc/mld/n2bs.h215
2 files changed, 245 insertions, 50 deletions
diff --git a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc b/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc
index 64c0cf16e..d32dec865 100644
--- a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc
+++ b/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.cc
@@ -25,11 +25,11 @@
static const int g_num_bits_per_byte = 8;
-std::string DoIt (int64_t number, size_t digits)
+std::string DoIt (long long number, char digits)
{
std::string retVal (digits, '0');
if (number != 0)
- for (int n = --digits; n >= 0; n--) {
+ for (char n = digits-1; n >= 0; n--) {
if (number & 1) {
retVal[n] = '1';
}
@@ -38,51 +38,63 @@ std::string DoIt (int64_t number, size_t digits)
return (retVal);
}
-std::string n2bs (int8_t number, size_t digits)
+std::string n2bs (char number, unsigned char digits)
{
- if (digits > (sizeof (int8_t) * g_num_bits_per_byte))
- digits = sizeof (int8_t);
- return DoIt ((int64_t) number, digits);
+ if (digits > (unsigned char)(sizeof (char) * g_num_bits_per_byte))
+ digits = sizeof (char) * g_num_bits_per_byte;
+ return DoIt ((long long) number, (char) digits);
}
-std::string n2bs (int16_t number, size_t digits)
+std::string n2bs (short number, unsigned char digits)
{
- if (digits > (sizeof (int16_t) * g_num_bits_per_byte))
- digits = sizeof (int16_t);
- return DoIt ((int64_t) number, digits);
+ if (digits > (unsigned char)(sizeof (short) * g_num_bits_per_byte))
+ digits = sizeof (short) * g_num_bits_per_byte;
+ return DoIt ((long long) number, (char) digits);
}
-std::string n2bs (int32_t number, size_t digits)
+std::string n2bs (int number, unsigned char digits)
{
- if (digits > (sizeof (int32_t) * g_num_bits_per_byte))
- digits = sizeof (int32_t);
- return DoIt ((int64_t) number, digits);
+ if (digits > (unsigned char)(sizeof (int) * g_num_bits_per_byte))
+ digits = sizeof (int) * g_num_bits_per_byte;
+ return DoIt ((long long) number, (char) digits);
}
-std::string n2bs (int64_t number, size_t digits)
+std::string n2bs (long number, unsigned char digits)
{
- if (digits > (sizeof (int64_t) * g_num_bits_per_byte))
- digits = sizeof (int64_t);
- return DoIt (number, digits);
+ if (digits > (unsigned char)(sizeof (long long) * g_num_bits_per_byte))
+ digits = sizeof (long long) * g_num_bits_per_byte;
+ return DoIt (number, (char) digits);
}
-std::string n2bs (u_int8_t number, size_t digits)
+std::string n2bs (long long number, unsigned char digits)
{
- if (digits > (sizeof (u_int8_t) * g_num_bits_per_byte))
- digits = sizeof (u_int8_t);
- return DoIt ((int64_t) number, digits);
+ if (digits > (unsigned char)(sizeof (long long) * g_num_bits_per_byte))
+ digits = sizeof (long long) * g_num_bits_per_byte;
+ return DoIt (number, (char) digits);
}
-std::string n2bs (u_int16_t number, size_t digits)
+std::string n2bs (unsigned char number, unsigned char digits)
{
- if (digits > (sizeof (u_int16_t) * g_num_bits_per_byte))
- digits = sizeof (u_int16_t);
- return DoIt ((int64_t) number, digits);
+ if (digits > (unsigned char)(sizeof (unsigned char) * g_num_bits_per_byte))
+ digits = sizeof (unsigned char) * g_num_bits_per_byte;
+ return DoIt ((long long) number, (char) digits);
}
-std::string n2bs (u_int32_t number, size_t digits)
+std::string n2bs (unsigned short number, unsigned char digits)
{
- if (digits > (sizeof (u_int32_t) * g_num_bits_per_byte))
- digits = sizeof (u_int32_t);
- return DoIt ((int64_t) number, digits);
+ if (digits > (unsigned char)(sizeof (unsigned short) * g_num_bits_per_byte))
+ digits = sizeof (unsigned short) * g_num_bits_per_byte;
+ return DoIt ((long long) number, (char) digits);
}
-std::string n2bs (u_int64_t number, size_t digits)
+std::string n2bs (unsigned int number, unsigned char digits)
{
- if (digits > (sizeof (u_int64_t) * g_num_bits_per_byte))
- digits = sizeof (u_int64_t);
- return DoIt ((int64_t) number, digits);
+ if (digits > (unsigned char)(sizeof (unsigned int) * g_num_bits_per_byte))
+ digits = sizeof (unsigned int) * g_num_bits_per_byte;
+ return DoIt ((long long) number, (char) digits);
+}
+std::string n2bs (unsigned long number, unsigned char digits)
+{
+ if (digits > (unsigned char)(sizeof (unsigned long long) * g_num_bits_per_byte))
+ digits = sizeof (unsigned long long) * g_num_bits_per_byte;
+ return DoIt ((long long) number, (char) digits);
+}
+std::string n2bs (unsigned long long number, unsigned char digits)
+{
+ if (digits > (unsigned char)(sizeof (unsigned long long) * g_num_bits_per_byte))
+ digits = sizeof (unsigned long long) * g_num_bits_per_byte;
+ return DoIt ((long long) number, (char) digits);
}
diff --git a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.h b/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.h
index 16ef4d758..5bd95c991 100644
--- a/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.h
+++ b/gr-error-correcting-codes/src/lib/libecc/mld/n2bs.h
@@ -25,21 +25,204 @@
#include <string>
-std::string n2bs (int8_t number, size_t digits);
-std::string n2bs (int16_t number, size_t digits);
-std::string n2bs (int32_t number, size_t digits);
-#if 1
-std::string n2bs (long number, size_t digits);
-#endif
-std::string n2bs (int64_t number, size_t digits);
-std::string n2bs (u_int8_t number, size_t digits);
-std::string n2bs (u_int16_t number, size_t digits);
-std::string n2bs (u_int32_t number, size_t digits);
-#if 1
-std::string n2bs (unsigned long number, size_t digits);
-#endif
-std::string n2bs (u_int64_t number, size_t digits);
-
-void cout_binary (int number, int digits);
+std::string n2bs (char number, unsigned char digits);
+std::string n2bs (short number, unsigned char digits);
+std::string n2bs (int number, unsigned char digits);
+std::string n2bs (long number, unsigned char digits);
+std::string n2bs (long long number, unsigned char digits);
+std::string n2bs (unsigned char number, unsigned char digits);
+std::string n2bs (unsigned short number, unsigned char digits);
+std::string n2bs (unsigned int number, unsigned char digits);
+std::string n2bs (unsigned long number, unsigned char digits);
+std::string n2bs (unsigned long long number, unsigned char digits);
+
+inline std::string n2bs (char number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (short number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (int number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long long number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned char number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned short number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned int number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long long number, char digits)
+{return (n2bs (number, (unsigned char) digits));};
+
+inline std::string n2bs (char number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (short number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (int number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long long number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned char number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned short number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned int number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long long number, unsigned short digits)
+{return (n2bs (number, (unsigned char) digits));};
+
+inline std::string n2bs (char number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (short number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (int number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long long number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned char number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned short number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned int number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long long number, short digits)
+{return (n2bs (number, (unsigned char) digits));};
+
+inline std::string n2bs (char number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (short number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (int number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long long number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned char number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned short number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned int number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long long number, unsigned int digits)
+{return (n2bs (number, (unsigned char) digits));};
+
+inline std::string n2bs (char number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (short number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (int number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long long number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned char number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned short number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned int number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long long number, int digits)
+{return (n2bs (number, (unsigned char) digits));};
+
+inline std::string n2bs (char number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (short number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (int number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long long number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned char number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned short number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned int number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long long number, unsigned long digits)
+{return (n2bs (number, (unsigned char) digits));};
+
+inline std::string n2bs (char number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (short number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (int number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long long number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned char number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned short number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned int number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long long number, long digits)
+{return (n2bs (number, (unsigned char) digits));};
+
+inline std::string n2bs (char number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (short number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (int number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long long number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned char number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned short number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned int number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long long number, unsigned long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+
+inline std::string n2bs (char number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (short number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (int number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (long long number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned char number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned short number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned int number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
+inline std::string n2bs (unsigned long long number, long long digits)
+{return (n2bs (number, (unsigned char) digits));};
#endif /* INCLUDED_N2BS_H */