From: Yossef Mendelssohn Date: 2011-12-09T02:37:27+09:00 Subject: Re: Confusing results from string multiplication On Dec 8, 12:09 pm, Rob Marshall wrote: > I could probably look at it all day and not know why the math > wasn't working. Possibly, but I'd hope not. At some point you should think about breaking the problem up into smaller bits and you'd see that it all works as intended except for the number -> string conversion, and then you'd end up understanding the problem. > what's happening is that 11 is > being converted to binary and then to a string, which means that the > precedence is either wrong or confusing. Because the only way I get to > 1011 is if the '*2' happens BEFORE the .to_s. Which means that the > precedence seems to be (in this case, and potentially in this case only) > to do the *2 BEFORE converting 11 to a string, which is just wrong, in > my opinion. In your opinion, methods can't have arguments, then. Of course the '*2' happens before the .to_s, since to_s needs the 2 before it can do anything. 11 is being converted to binary and then to a string because that's how to_s manages to give string representations in other bases. -- -yossef