Skip to content

Commit

Permalink
printf: fix "%.0f" formatting bug [closes #1081]
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Aug 2, 2012
1 parent 8f45f12 commit a6ad7ef
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion base/printf.jl
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,8 @@ function _jl_printf_f(flags::ASCIIString, width::Int, precision::Int, c::Char)
if precision > 0
push(blk.args, :(_jl_print_fixed(out,$precision)))
else
push(blk.args, :(write(out, pointer(_jl_digits), pt)))
push(blk.args, :(write(out, pointer(_jl_digits), len)))
push(blk.args, :(while pt >= (len+=1) write(out,'0') end))
contains(flags,'#') && push(blk.args, :(write(out, '.')))
end
# print space padding
Expand Down

3 comments on commit a6ad7ef

@dreiss-isb
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not entirely sure if it was this commit that did it, but now the sprintf statement in my code is broken. Here is the error:

in anonymous: int_dec not defined
in anonymous at no file
in fprintf at printf.jl:774
in fprintf at printf.jl:775
in sprint at io.jl:265
in sprint at io.jl:269
in sprintf at printf.jl:777

The sprintf call looks like this:

sprintf( "*** %4d %4d %4d %4d %4d %4d\tMAP = %.3f\t%.3f\t%.3f\t%s", iter1, iter2,
tries, wind, shft, size( pssm, 1 ), best_MAP, MAP, best_MAP_2, pssm_string )

where best_MAP, MAP, and best_MAP_2 are all Floats.

git-reset -ing back to the commit right before this one fixes the error.

@StefanKarpinski
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry about that. I actually just introduced a new printf interface in 04f542d. Basically, just stick an @ sign in front of that call and you should be all good (and much, much faster too). Let me know if it works.

@StefanKarpinski
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, also, it wasn't this commit that caused the problem, but rather, 0213f82. Close enough.

Please sign in to comment.