Modification of to_float function to handle exponent and sign