thanks all.. end of the day simple silly one .. went unnoticed .. On Sunday, April 16, 2017 at 11:53:11 PM UTC+5:30, Janne Snabb wrote: > > It does not do this. > > It would be nice in most cases if it did. > > But some times extra parenthesis are useful for making some formula > easier to read. > > > Janne Snabb > sn...@epipe.com <javascript:> > > On 2017-04-15 01:36, Jesper Louis Andersen wrote: > > If I remember correctly, you can just go wild and put in all the > > parenthesis you want and "go fmt" will clean it up for you wrt > > precedence rules > > > > > > On Fri, Apr 14, 2017, 14:38 Elias Naur <elias...@gmail.com <javascript:> > > <mailto:elias...@gmail.com <javascript:>>> wrote: > > > > Your expression is (effectively) ((z*z-x)/2)*z. Use parentheses to > > group the 2*z term: (z*z-x)/(2*z). > > > > - elias > > > > > > On Friday, April 14, 2017 at 2:30:33 PM UTC+2, ksam...@redhat.com > > <mailto:ksam...@redhat.com> wrote: > > > > Hello, > > > > Am a newbie to golang, and was trying myself with golang tour. > > > > > > I was trying https://tour.golang.org/flowcontrol/8 and below is > > my code snippet for the same > > > > | > > package main > > > > import ( > > "fmt" > > "math" > > ) > > > > func Sqrt(x float64) float64 { > > z := float64(1) > > > > for i := 0; i < 10; i++ { > > //z = z - (z*z-x)/2*z -- this does not work why ??? > > z = z - (float64(z*z)-float64(x))/float64(2*z) > > } > > return float64(z) > > } > > > > func main() { > > fmt.Printf("Ans: %0.2f \n", Sqrt(4)) > > fmt.Printf("math.Sqrt: %0.2f", math.Sqrt(4)) > > } > > > > | > > > > I assume that all data is handled as float64 only, if you see > > the commented codes not seem to work especially for simple > > Sqrt(4) i get an answer of 1.76 instead of 2 ;) .. but after i > > did the casting to float64(..) it seem to work right.. > > > > I am not able to understand why .. > > > > any thoughts ? > > > > -- > > You received this message because you are subscribed to the Google > > Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, > > send an email to golang-nuts...@googlegroups.com <javascript:> > > <mailto:golang-nuts+unsubscr...@googlegroups.com <javascript:>>. > > For more options, visit https://groups.google.com/d/optout. > > > > -- > > You received this message because you are subscribed to the Google > > Groups "golang-nuts" group. > > To unsubscribe from this group and stop receiving emails from it, send > > an email to golang-nuts...@googlegroups.com <javascript:> > > <mailto:golang-nuts+unsubscr...@googlegroups.com <javascript:>>. > > For more options, visit https://groups.google.com/d/optout. >
-- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.