「テンプレート:Roundtozero」の版間の差分

提供:脳科学辞典
ナビゲーションに移動 検索に移動
(1版)
 
(相違点なし)

2015年3月14日 (土) 12:15時点における最新版


This template rounds towards zero (aka truncates) a numeric expression to a limited number of decimal places.

Usage:
{{Roundtozero|expression}}
{{Roundtozero|expression|decimals}}
Both parameters can be any valid numeric expression.
The decimals parameter defaults to 0 and is rounded to the nearest integer.
decimals can be negative to round down to a multiple of a power of ten.
Examples:
{{Roundtozero|3.14159|3}} = 3.141
{{Roundtozero|-3.14159|3}} = -3.141
{{Roundtozero|314159|-3}} = 314000
{{Roundtozero|-314159|-3}} = -314000
{{Roundtozero|+1/3}} = 0
{{Roundtozero|2<1}} = 0
{{Roundtozero|-1/3}} = 0
{{Roundtozero|-2/3}} = 0
For expressions containing equal signs use 1=expression - the second example fails:
{{Roundtozero|1=3<=4}} = 1
{{Roundtozero|3<=4}} = 構文エラー: 予期しない演算子 < です。