Name |
float()浮点转换 |
Examples |
int i = 65; float f = float(i); println(i + ” : ” + f); // Prints “65 : 65.0” |
Description |
Converts an int or String to its floating point representation. An int is easily converted to a float, but the contents of a String must resemble a number, or NaN (not a number) will be returned. For example, float(“1234.56”) evaluates to 1234.56, but float(“giraffe”) will return NaN. When an array of int or String values is passed in, then a floating point array of the same length is returned. 将 int 或字符串转换为其浮点表示形式。int 很容易转换为浮点型, 但字符串的内容必须类似于数字, 否则将返回 nan (而不是数字)。例如, 浮动 (“1234.56”) 的计算结果为 1234.56, 但浮动 (“长颈鹿“) 将返回 nan。
在传入 int 或字符串值的数组时, 返回相同长度的浮点数组。 |
- 本文固定链接: http://iprocessing.cn/2017/07/20/float浮点转换/
- 转载请注明: 卡萨布兰卡 于 Processing编程艺术 发表