Volendone fare una versione con un numero variabile di bit, ho scritto una cosa del genere
Secondo te potrebbe andare bene?codice:static inline float readF(const unsigned char * ptr, const int Size) { unsigned int PSize = static_cast<unsigned int>(pow(2,Size)); unsigned short temp; float out=(ptr[1] & PSize) ? -1.f : 0.f; unsigned char * tempPtr=(unsigned char *) & temp; tempPtr[0]=ptr[0]; tempPtr[1]=ptr[1] & PSize - 1; out += static_cast<float>(temp) / PSize; return out; }