首页 > 文档 > float()浮点转换
2017
07-20

float()浮点转换

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 或字符串值的数组时, 返回相同长度的浮点数组。



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

留下一个回复

你的email不会被公开。