I have a string matching the following regex \-?[0-9]*\.[0-9]+
which supposedly represents a IEEE floating point number. It could be single or double precision and I know the type in advance. I need to check if it could be interpreted as a valid value in given precission. Something like:
val is_valid_float: string -> bool
val is_valid_double: string -> bool
For double precision numbers, I can just parse it using float_of_string
and catch the exception. I am unsure how to deal with single precision.