首页 > 文档 > sq() 平方
2017
07-19

sq() 平方

名称:sq()

 

例子:

sq() 平方 - 第1张  | Processing编程艺术

noStroke();
float a = sq(1);   // Sets ‘a’ to 1
float b = sq(-5);  // Sets ‘b’ to 25
float c = sq(9);   // Sets ‘c’ to 81
rect(0, 25, a, 10);
rect(0, 45, b, 10);
rect(0, 65, c, 10);

 

描述:

一个数的平方(或者说,乘以其本身)。 除0外,结果总是一个正数,因为负负得正。 例如,-1 * -1 = 1。

 

语法:

sq(n)

 

参数:

n float: number to square        要平方的数

 

返回:float

 

相关:

sqrt()

 



最后编辑:
作者:Hewes
这个作者貌似有点懒,什么都没有留下。

留下一个回复

你的email不会被公开。