You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 1745 Reporter: administrator Status: closed Resolution: fixed Priority: normal Severity: minor Category: ~DO NOT USE (was: OCaml general)
Scanf doesn't seem to like the floating-point format used by
string_of_float. string_of_float is happy to print nothing after the
decimal point, but as the following code demonstrates, scanf will
raise an exception if the string ends directly after the decimal
point:
let scanf_test () =
Printf.printf "got %f.\n" (Scanf.sscanf " 24. " " %f" (fun x -> x));
(* now no space after the point *)
Scanf.sscanf " 24." " %f" (fun x -> x)
scanf_test ();;
got 24.000000.
Exception: Scanf.Scan_failure "scanf: bad input at char number 4: bad int".
I suppose one could argue that string_of_float is matched with
float_of_string and scanf is supposed to be matched with printf, and
the two pairs shouldn't necessarily be combined, but it seems like an
unnecessary incompatibility.
Thanks for some great software!
Wheeler
The text was updated successfully, but these errors were encountered:
Scanf doesn't seem to like the floating-point format used by
string_of_float. string_of_float is happy to print nothing after the
decimal point, but as the following code demonstrates, scanf will
raise an exception if the string ends directly after the decimal
point:
let scanf_test () =
Printf.printf "got %f.\n" (Scanf.sscanf " 24. " " %f" (fun x -> x));
(* now no space after the point *)
Scanf.sscanf " 24." " %f" (fun x -> x)
scanf_test ();;
got 24.000000.
Exception: Scanf.Scan_failure "scanf: bad input at char number 4: bad int".
Thanks for the bug report: this behaviour was due to a wrong treatment
of the end of input condition and has been corrected some time ago
into the working sources.
I suppose one could argue that string_of_float is matched with
float_of_string and scanf is supposed to be matched with printf, and
the two pairs shouldn't necessarily be combined, but it seems like an
unnecessary incompatibility.
I don't clearly grasp what you mean, here. What is the incompatibility
you want to get rid of ?
Original bug ID: 1745
Reporter: administrator
Status: closed
Resolution: fixed
Priority: normal
Severity: minor
Category: ~DO NOT USE (was: OCaml general)
Bug description
Full_Name: Wheeler Ruml
Version: 3.06
OS: linux
Submission from: katsura.parc.xerox.com (13.2.18.21)
Scanf doesn't seem to like the floating-point format used by
string_of_float. string_of_float is happy to print nothing after the
decimal point, but as the following code demonstrates, scanf will
raise an exception if the string ends directly after the decimal
point:
let scanf_test () =
Printf.printf "got %f.\n" (Scanf.sscanf " 24. " " %f" (fun x -> x));
(* now no space after the point *)
Scanf.sscanf " 24." " %f" (fun x -> x)
scanf_test ();;
got 24.000000.
Exception: Scanf.Scan_failure "scanf: bad input at char number 4: bad int".
I suppose one could argue that string_of_float is matched with
float_of_string and scanf is supposed to be matched with printf, and
the two pairs shouldn't necessarily be combined, but it seems like an
unnecessary incompatibility.
Thanks for some great software!
Wheeler
The text was updated successfully, but these errors were encountered: