注意:该中文文档为社区驱动的非官网文档,可能存在错译、漏译或过时等问题,请以官网文档 Documentation 为准,如发现错漏,也欢迎 您的贡献镜像)。Typst 非官方中文交流 QQ 群:793548390
Warning: the Chinese document is a community-driven non-official document, there may be mistranslation, omission or outdated problems, please refer to the official website documentation.
Typst 中文文档

float

A floating-point number.

A limited-precision representation of a real number. Typst uses 64 bits to store floats. Wherever a float is expected, you can also pass an integer.

You can convert a value to a float with this type's constructor.

Example

#3.14 \
#1e4 \
#(10 / 4)
Preview

构造函数
如果类型具有构造函数,可以像函数一样调用它来创建一个该类型的值。

Converts a value to a float.

#float(false) \
#float(true) \
#float(4) \
#float(40%) \
#float("2.7") \
#float("1e5")
Preview

value
bool int float ratio str
必需参数位置参数
位置参数按顺序传入,不带名称。

The value that should be converted to a float.