Thomas Lumley <[EMAIL PROTECTED]> writes: > On Fri, 6 Jan 2006, [EMAIL PROTECTED] wrote: > > > hi - in version 2.1 the command > > > > >-2^2 > > > > gives > > > > -4 > > > > as the answer. (-2)^2 is evaluated correctly. > > So is -2^2. The precedence of ^ is higher than that of unary minus. It > may be surprising, but it *is* documented and has been in S for a long > time.
Pretty much standard too, for languages that have an exponentiation operator. AFAICS Fortran, Perl, SAS all have ** at higher precedence than unary minus (or equal, but evaluate right to left). Stata seems like it might be the exception. -- O__ ---- Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - ([EMAIL PROTECTED]) FAX: (+45) 35327907 ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel