Connect IQ > APIメモ > Toybox > Lang > Float


Class: Toybox::Lang::Float


Floats are 32 bit floating point values. A decimal number is Float by default unless the 'd' prefix is used.

  • Since : 1.0.0

関数(要約)

  • (Float) abs : Use abs() to get the Absolute value of the Float.
  • (String) format(format) : フォーマット文字列を用いて、 Float を整形して出力する
  • (Double) toDouble : Convert the Float to a Double with toDouble().
  • (Float) toFloat : Convert to a Float with toFloat().
  • (Long) toLong : Convert the Float to a Long with toLong().
  • (Number) toNumber : Convert the Float to a Number with toNumber().

Instance Method Details

(Float) abs : Use abs() to get the Absolute value of the Float.

  • Returns : (Float) Absolute value of the Float
  • Since : 1.0.0

(String) format(format) : フォーマット文字列を用いて、 Float を整形して出力する

フォーマット文字列は c の stdio の printf 関数で用いられるものに似ているが、 length オプションは使えない。

"%[flags][width][.precision]specifier"

  • サポートされている specifiers は d, i, u, o, x, X, f, e, E, g, G.
    • d : 10進整数
    • u : 符号なし10進整数
    • x : 16進整数(小文字で表記)
    • x : 16進整数(大文字で表記)
    • o : 8進整数
    • f : 浮動小数点数
    • e : 3.9265e+2
    • E : 3.9265E+2
    • g : e と f で短い方
    • G : E と f で短い方
  • flags : + とすると、常に符号を出す。supports only + and 0
  • width : supports only numbers (* is not supported)
  • .precision : 小数点以下の桁数。数字のみ有効( * は無効)

  • Returns : (String) A formatted String
  • Since : 1.0.0

(Double) toDouble : Float を Double に変換する

  • Returns : (Double) A Double object
  • Since : 1.0.0

(Float) toFloat : Convert to a Float with toFloat().

  • Returns : (Float) A Float object
  • Since : 1.0.0

(Long) toLong


Convert the Float to a Long with toLong().

Returns:

   (Long) —

   A Long object

Since:

   1.0.0

  • (Number) toNumber

Convert the Float to a Number with toNumber(). Since the number is a float the value will be rounded toward 0. For example, 6.8 becomes 6 and -5.7 becomes -5.

Returns:

   (Number) —

   A Number object

Since:

   1.0.0
最終更新:2016年03月02日 23:46