Convert variable to different data type
convertsB
= cast(A
,新级
)A
to the data type (class)新级
, where新级
is the name of a built-in data type compatible withA
。这cast
function truncates any values inA
that are outside the range of新级
to the nearest endpoint.
将浮点数转换为整数时cast
function rounds the number to the nearest integer. If the floating-point number has a fractional part of exactly 0.5, then it rounds away from zero to the integer with larger magnitude.