Darkmatter5 Posted February 12, 2009 Share Posted February 12, 2009 What is the notation to square a number? Like 2^2 =4 I tried: $square=2^2; echo "The square of 2 is $square"; It echos "The square of 2 is 0". Link to comment https://forums.phpfreaks.com/topic/144920-solved-how-do-you-square-a-number/ Share on other sites More sharing options...
PFMaBiSmAd Posted February 12, 2009 Share Posted February 12, 2009 http://www.php.net/manual/en/function.pow.php ^ is an bitwise XOR if I remember correctly. Link to comment https://forums.phpfreaks.com/topic/144920-solved-how-do-you-square-a-number/#findComment-760452 Share on other sites More sharing options...
Mark Baker Posted February 12, 2009 Share Posted February 12, 2009 or if it's simply squaring rather than higher powers (e.g. cube) that you want: $square=2*2; echo "The square of 2 is $square"; What do they teach in mathematics in schools these days? Link to comment https://forums.phpfreaks.com/topic/144920-solved-how-do-you-square-a-number/#findComment-760456 Share on other sites More sharing options...
Darkmatter5 Posted February 12, 2009 Author Share Posted February 12, 2009 pow() worked great! Thanks! Link to comment https://forums.phpfreaks.com/topic/144920-solved-how-do-you-square-a-number/#findComment-760475 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.