[R] Strange sprintf Behavior

Marc Schwartz marc_schwartz at me.com
Wed Apr 2 14:17:11 CEST 2014


On Apr 2, 2014, at 6:32 AM, Michael Smith <my.r.help at gmail.com> wrote:

> All,
> 
> I'm getting this:
> 
>> sprintf("%.17f", 0.8)
> [1] "0.80000000000000004"
> 
> Where does the `4` at the end come from? Shouldn't it be zero at the
> end? Maybe I'm missing something.


Hi,

First, please start a new thread when posting, do not just reply to an existing thread and change the subject line. Your post gets lost in the archive and is improperly linked to other posts.

Second, see the Most Frequently Asked Question:

  http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-doesn_0027t-R-think-these-numbers-are-equal_003f

Regards,

Marc Schwartz




More information about the R-help mailing list