情報アイコン
情報 / Info
当サイトは、Typst GmbHの許諾を得て、日本語コミュニティ「Typst Japan Community」がTypst v0.13.1の公式ドキュメントを翻訳したものです。誤訳や古い情報が含まれている可能性があるため、公式ドキュメントとの併用を推奨します。翻訳の改善やサイトの機能向上について、GitHubでのIssueやPull Requestを歓迎します。コミュニティにご興味のある方はDiscordサーバー「くみはんクラブ」にぜひご参加ください。
This site provides a Japanese translation of the Typst v0.13.1 documentation maintained by the "Typst Japan Community" with permission from Typst GmbH. We recommend using this alongside the official documentation. We welcome contributions through Issues and Pull Requests on our GitHub repository for both translation improvements and website enhancements. Feel free to join our Discord server "Kumihan Club".
言語アイコン
未翻訳

このページはまだ翻訳されていません。原文の内容が表示されています。

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.

NaN and positive infinity are available as float.nan and float.inf respectively.

Example

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

コンストラクタ
ヘルプアイコン

Converts a value to a float.

  • Booleans are converted to 0.0 or 1.0.
  • Integers are converted to the closest 64-bit float. For integers with absolute value less than calc.pow(2, 53), this conversion is exact.
  • Ratios are divided by 100%.
  • Strings are parsed in base 10 to the closest 64-bit float. Exponential notation is supported.
#float(false) \
#float(true) \
#float(4) \
#float(40%) \
#float("2.7") \
#float("1e5")
Preview

value
Required
ヘルプアイコン
Positional
ヘルプアイコン

The value that should be converted to a float.

定義
ヘルプアイコン

is-nan

Checks if a float is not a number.

In IEEE 754, more than one bit pattern represents a NaN. This function returns true if the float is any of those bit patterns.

self.is-nan(
)->
右矢印アイコン
例を表示
#float.is-nan(0) \
#float.is-nan(1) \
#float.is-nan(float.nan)
Preview

is-infinite

Checks if a float is infinite.

Floats can represent positive infinity and negative infinity. This function returns true if the float is an infinity.

self.is-infinite(
)->
右矢印アイコン
例を表示
#float.is-infinite(0) \
#float.is-infinite(1) \
#float.is-infinite(float.inf)
Preview

signum

Calculates the sign of a floating point number.

  • If the number is positive (including +0.0), returns 1.0.
  • If the number is negative (including -0.0), returns -1.0.
  • If the number is NaN, returns float.nan.
self.signum(
)->
右矢印アイコン
例を表示
#(5.0).signum() \
#(-5.0).signum() \
#(0.0).signum() \
#float.nan.signum()
Preview

from-bytes

Interprets bytes as a float.

float.from-bytes()->
右矢印アイコン
例を表示
#float.from-bytes(bytes((0, 0, 0, 0, 0, 0, 240, 63))) \
#float.from-bytes(bytes((63, 240, 0, 0, 0, 0, 0, 0)), endian: "big")
Preview

bytes
Required
ヘルプアイコン
Positional
ヘルプアイコン

The bytes that should be converted to a float.

Must have a length of either 4 or 8. The bytes are then interpreted in IEEE 754's binary32 (single-precision) or binary64 (double-precision) format depending on the length of the bytes.

endian

The endianness of the conversion.

使用可能な文字列値:
  • big

    Big-endian byte order: The highest-value byte is at the beginning of the bytes.

  • little

    Little-endian byte order: The lowest-value byte is at the beginning of the bytes.

デフォルト値:

"little"

to-bytes

Converts a float to bytes.

self.to-bytes()->
右矢印アイコン
例を表示
#array(1.0.to-bytes(endian: "big")) \
#array(1.0.to-bytes())
Preview

endian

The endianness of the conversion.

使用可能な文字列値:
  • big

    Big-endian byte order: The highest-value byte is at the beginning of the bytes.

  • little

    Little-endian byte order: The lowest-value byte is at the beginning of the bytes.

デフォルト値:

"little"

size

The size of the resulting bytes.

This must be either 4 or 8. The call will return the representation of this float in either IEEE 754's binary32 (single-precision) or binary64 (double-precision) format depending on the provided size.

デフォルト値:

8

検索