Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printf.sprintf "%1.F" 123.456 returns "12." !! #4902

Closed
vicuna opened this issue Oct 30, 2009 · 1 comment
Closed

Printf.sprintf "%1.F" 123.456 returns "12." !! #4902

vicuna opened this issue Oct 30, 2009 · 1 comment
Labels

Comments

@vicuna
Copy link

vicuna commented Oct 30, 2009

Original bug ID: 4902
Reporter: furuse
Status: closed (set by @damiendoligez on 2009-10-30T12:45:30Z)
Resolution: fixed
Priority: normal
Severity: major
Version: 3.11.1
Fixed in version: 3.11.2+dev
Category: ~DO NOT USE (was: OCaml general)

Bug description

The summary tells everything.

The fix is easy:

diff --git a/stdlib/printf.ml b/stdlib/printf.ml
--- a/stdlib/printf.ml
+++ b/stdlib/printf.ml
@@ -435,7 +435,7 @@
let add_dot sfmt s =
if s.[0] = ' ' || s.[0] = '+' || s.[0] = '0'
then String.sub s 1 (l - 1) ^ "."

  •    else String.sub s 0 (l - 1) ^ "." in
    
  •    else String.sub s 0 l ^ "." in
    
     let rec loop i =
       if i >= l then add_dot sfmt s else
    
@vicuna
Copy link
Author

vicuna commented Oct 30, 2009

Comment author: furuse

I see the function format_float_lexem is largely rewritten in the trunk version. The issue is gone in the trunk, but I think it is still worth reporting.

@vicuna vicuna closed this as completed Oct 30, 2009
@vicuna vicuna added the bug label Mar 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant