Class CFW_Util_Number

Description

数値関連の便利メソッド

  • author: okada

Located in /Util/Number.php (line 9)


	
			
Method Summary
static Integer boolToInt (Boolean $value)
static unknown_type boolValue (unknown_type $value)
static string defaultFormat (unknown_type $value)
static unknown_type distance ($origin $origin, $position $position)
static string format (object $value)
static string formatBool (Boolean $value, unknown_type $trueExpression, unknown_type $falseExpression)
static string formatBoolYesNo (Boolean $value)
static string formatBoolYN (Boolean $value)
static string formatCurrency (decimal $value)
static string formatNumber (decimal $value)
static string formatZero (Number $value, Number $width)
static Boolean isInRange (Number $target, Number $min, Number $max)
static Boolean parseBool (string $s)
static Number power (decimal $x, int $y)
static $result round (double $value, int $scale)
static $result roundDown (double $value, int $scale)
static $result roundUp (double $value, int $scale)
static integer toByte (object $o)
static void toFloat ( $o)
static number|number toInteger (unknown_type $o)
static 数値型 toNumber (object $o, [integer $precision = 20], [integer $scale = 0])
Methods
static method boolToInt (line 90)

Booleanを1/0にして返す。

trueなら1,falseなら0

  • return: 変換結果
  • access: public
static Integer boolToInt (Boolean $value)
  • Boolean $value: 入力値
static method boolValue (line 64)

Booleanが期待される値をBooleanに変換

  • return: 入力値のBoolean表現
  • access: public
static unknown_type boolValue (unknown_type $value)
  • unknown_type $value: 入力値
static method defaultFormat (line 111)

デフォルトの書式で書式化

  • return: 書式化結果文字列
  • access: public
static string defaultFormat (unknown_type $value)
  • unknown_type $value: 入力値
static method distance (line 192)

2値の距離

たとえば 0から2の距離は 2

  • return: 距離。位置が基準位置の左側の場合負
  • access: public
static unknown_type distance ($origin $origin, $position $position)
  • $origin $origin: 基準位置
  • $position $position: 位置
static method format (line 100)

デフォルトの書式で書式化

  • return: 書式化結果文字列
  • access: public
static string format (object $value)
  • object $value: 入力値
static method formatBool (line 125)

boolの真偽に対し文字列を割り当てて返す

  • return: 書式化結果文字列
  • access: public
static string formatBool (Boolean $value, unknown_type $trueExpression, unknown_type $falseExpression)
  • Boolean $value: 入力値
  • unknown_type $trueExpression: 値がtrueの場合の出力
  • unknown_type $falseExpression: 値がfalseの場合の出力
static method formatBoolYesNo (line 146)

boolの真偽に対し文字列(YesかNo)を割り当てて返す

  • return: 書式化結果文字列
  • access: public
static string formatBoolYesNo (Boolean $value)
  • Boolean $value: 入力値
static method formatBoolYN (line 137)

boolの真偽に対し文字列(YかN)を割り当てて返す

  • return: 書式化結果文字列
  • access: public
static string formatBoolYN (Boolean $value)
  • Boolean $value: 入力値
static method formatCurrency (line 165)

通貨形式書式化

  • return: 書式化結果文字列
  • access: public
static string formatCurrency (decimal $value)
  • decimal $value: 入力値
static method formatNumber (line 155)

桁区切り書式化

  • return: 書式化結果文字列
  • access: public
static string formatNumber (decimal $value)
  • decimal $value: 入力値
static method formatZero (line 214)

0埋め書式化

  • return: 書式化結果文字列
  • access: public
static string formatZero (Number $value, Number $width)
  • Number $value: 入力値
  • Number $width: 出力文字数
static method isInRange (line 203)

指定数値が範囲内にあるかチェック

  • return: 入力値が最小値から最大値の範囲にあればtrue
  • access: public
static Boolean isInRange (Number $target, Number $min, Number $max)
  • Number $target: 入力値
  • Number $min: 最小値
  • Number $max: 最大値
static method parseBool (line 175)

文字列を解析してBooleanを返す

  • return: 解析結果
  • access: public
static Boolean parseBool (string $s)
  • string $s: 解析対象文字列
static method power (line 235)

decimalのべき乗。

有理数乗はわからないので保留。

  • return: decimalのべき乗。
  • access: public
static Number power (decimal $x, int $y)
  • decimal $x: 基数
  • int $y: べき数
static method round (line 255)

指定精度で四捨五入

  • return: 四捨五入結果
  • access: public
static $result round (double $value, int $scale)
  • double $value: 入力値
  • int $scale: 精度
static method roundDown (line 279)

指定精度で切り捨て

  • return: 四捨五入結果
  • access: public
static $result roundDown (double $value, int $scale)
  • double $value: 入力値
  • int $scale: 精度
static method roundUp (line 265)

指定精度で切り上げ

  • return: 四捨五入結果
  • access: public
static $result roundUp (double $value, int $scale)
  • double $value: 入力値
  • int $scale: 精度
static method toByte (line 25)

byte型が期待される値を0~255内のint型に変換する

  • access: public
static integer toByte (object $o)
  • object $o
static method toFloat (line 55)
  • access: public
static void toFloat ( $o)
  • $o
static method toInteger (line 15)

整数値に変換

  • access: public
static number|number toInteger (unknown_type $o)
  • unknown_type $o
static method toNumber (line 42)

数値型に変換(精度指定付き)

  • access: public
static 数値型 toNumber (object $o, [integer $precision = 20], [integer $scale = 0])
  • object $o
  • integer $precision
  • integer $scale

Documentation generated on Fri, 25 Dec 2009 21:43:06 +0900 by phpDocumentor 1.4.3