Pow<\/strong> method that can be used to calculate x to the power y. <\/p>\n\n\n\nBelow is the signature of the function. It takes input as two float arguments and returns a float<\/p>\n\n\n\n
func Pow(x, y float64) float64<\/code><\/pre>\n\n\n\nThe same function can also be used to calculate the square or cube of a number. Just pass the second argument y as 2 in case of square<\/strong> and 3 in case of cube<\/strong><\/p>\n\n\n\n<\/span>Code<\/strong><\/span><\/h1>\n\n\n\npackage main\n\nimport (\n \"fmt\"\n \"math\"\n)\n\nfunc main() {\n \/\/Power for integers\n res := math.Pow(2, 10)\n fmt.Println(res)\n\n \/\/Power for float\n res = math.Pow(1.5, 2)\n fmt.Println(res)\n\n \/\/Anything to power 0 is 1\n res = math.Pow(3, 0)\n fmt.Println(res)\n}<\/code><\/pre>\n\n\n\nOutput:<\/strong><\/p>\n\n\n\n1024\n2.25\n1<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"Table of Contents OverviewCode Overview math package of GO provides a Pow method that can be used to calculate x to the power y. Below is the signature of the function. It…<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[3,4,240],"class_list":["post-1870","post","type-post","status-publish","format-standard","hentry","category-tech","tag-go","tag-golang","tag-power"],"yoast_head":"\n
Calculate x^y - Pow() in Go (Golang) - Welcome To Golang By Example<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n