#include char toFloat(float arg) { char sign = (arg < 0) ? 1 : 0; arg = fabsf(arg); int expo = (int)log2f(arg); if (expo < -3) { expo = -3; } else if (expo > 4) { expo = 4; } // Normalize the mantissa float mantissa = arg / powf(2, expo); // Convert mantissa to 4-bit representation char mantissa_bits = (char)(mantissa * 16); // Combine the sign, expo, and mantissa bits char result = (sign << 7) | ((expo + 3) << 4) | mantissa_bits; return result; }