--0016364d212f578ef20483a94b5e Content-Type: text/plain; charset=ISO-8859-1 Hi, On 7 April 2010 19:02, Yukihiro Matsumoto <matz / ruby-lang.org> wrote: > Hi, > > As I stated in [ruby-core:27631], I don't object about having two > string representation, one "human readable" and the other "more > verbose". Even though I am not fully against, it doesn't mean, I > enjoy having two representation. Float is float is float. We should > know about error when you treat with float, shouldn't we? > > Anyway, I feel like we still have two points: > > (1) We've got consensus which method to behave which so far. Since > #inspect is a method for "human readable" string representation, > I think it is more suitable to get "human readable" float > representation. Others want to #to_s to be "human readable" to > ease "Float #{f}". > > (2) Besides that, I am not sure whether the old behavior is the best > way to generate "human readable" representation. > > matz. > > Then let's choose which representation is "human readable", maybe a third one? I spoke a bit about that in my last post, while I fear I'm more of a beginner about technique: So, double have a range (between two of them) of 2e-52 ~ 10e-16. Should we then round at 15~16 digits ? > n .4 - 0.1 - 1.2 0.09999999999999987 > "%.15f" % n "0.100000000000000" > "%.16f" % n "0.0999999999999999" So I think most people would agree with the "%.15f" result (without the zeros of course). The question is then: How to do it properly ? P.S.: To my opinion, #inspect is usually more verbose than #to_s, so I continue staying straight in my idea. The bad thing with Float is you currently still need to "my Float: #{"%.2f" % f}" Inspect is, to my opinion, used mostly when debugging, almost never to print result. So if there is a verbose representation, I think it belongs to #inspect. (I expect to have precise, even too verbose output when I 'p f') --0016364d212f578ef20483a94b5e Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable <div class="gmail_quote">Hi,</div><div class="gmail_quote">On 7 April 2010 19:02, Yukihiro Matsumoto <span dir="ltr"><matz / ruby-lang.org></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"> Hi,<br><br>As I stated in [ruby-core:27631], I don't object about having two<br> string representation, one "human readable" and the other "more<br> verbose". ¨Βφετθουηθ αν ξοζυμμαηαιξστ¬ ιτ δοεσ³Ή»νεαξΙΌβςenjoy having two representation. ¨Βμοατ ισ ζμοαισ ζμοατ® ¨ΒσθουμδΌβςΎ know about error when you treat with float, shouldn't we?<br> <br> Anyway, I feel like we still have two points:<br> <br> (1) We've got consensus which method to behave which so far. ¨ΒιξγεΌβςΎ inspect is a method for "human readable" string representation,<br> ¨Β τθιξιτ ισ νοςε συιταβμε το ηε¦ρυοτ»θυναςεαδαβμε¦ρυοτ» ζμοατΌβς ¨Βεπςεσεξτατιοξ® ¨Βτθεςχαξτ το £τοίτο βε ¦ρυοτ»θυναςεαδαβμε¦ρυοτ» τοΌβςΎ ¨Βασ¦ρυοτ»Ζμοα£ϋζύ¦ρυοτ»®Όβς<br> (2) Besides that, I am not sure whether the old behavior is the best<br> ¨Βαω το ηεξεςατε ¦ρυοτ»θυναςεαδαβμε¦ρυοτ» ςεπςεσεξτατιοξ®Όβς<br> ¨Βατϊ®ΌβςΎ <br></blockquote><div>/div></div>Then let's choose which representation is "human readable", maybe a third one?<div><br></div><div>Ipoke a bit about that in my last post, while I fear I'm more of a beginner about technique:</div> <div><br></div><div><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: 13px; border-collapse: collapse; ">So, doubleave a range (between two of them) of 2e-52 ~ 10e-16. Should we then roundt<br> 15~16 digits ?<br><br>> n = 1.4 - 0.1 - 1.2<br>=> 0.09999999999999987<br>> "%.15f" % n<br>=> "0.100000000000000"<br>> "%.16f" % n<br>=> "0.0999999999999999"</span></div> <div><br></div><div>So I think most people would agree with the "%.15f" result (without the zeros of course).</div><div>The question is then: How to do it properly ?</div><div><br></div><div>P.S.: To my opinion, #inspect is usually more verbose than #to_s, so I continue staying straight iny idea.</div> <div>The bad thing with Float is you currently still need to "my Float: #{"%.2f" % f}"</div><div>Inspect is, to my opinion, used mostly when debugging, almost never to print result.</div><div>So if there is a verbose representation, I think it belongs to #inspect.</div> <div>(I expect to have precise, even too verbose output when I 'p f')</div> --0016364d212f578ef20483a94b5e--