Coffeescript-math-ceil
提供:Dev Guides
CoffeeScript Math-ceil()
説明
- ceil()*メソッドは数値を受け入れ、そのceil値を返します。
構文
以下に、JavaScriptの* ceil()*メソッドの構文を示します。 CoffeeScriptコードで同じメソッドを使用できます。
Math.ceil( x )
例
次の例は、CoffeeScriptでの* ceil()メソッドの使用法を示しています。 このコードを *math_ceil.coffee という名前のファイルに保存します。
value = Math.ceil 90.15
console.log "The ceil value of 90.15 is : " + value
value = Math.ceil 15.90
console.log "The ceil value of 15.90 is : " + value
value = Math.ceil -90.15
console.log "The ceil value of -90.15 is : " + value
value = Math.ceil -15.90
console.log "The ceil value of -15.90 is : " + value
- コマンドプロンプト*を開き、以下に示すように.coffeeファイルをコンパイルします。
c:\> coffee -c math_ceil.coffee
コンパイル時に、次のJavaScriptが提供されます。
//Generated by CoffeeScript 1.10.0
(function() {
var value;
value = Math.ceil(90.15);
console.log("The ceil value of 90.15 is : " + value);
value = Math.ceil(15.90);
console.log("The ceil value of 15.90 is : " + value);
value = Math.ceil(-90.15);
console.log("The ceil value of -90.15 is : " + value);
value = Math.ceil(-15.90);
console.log("The ceil value of -15.90 is : " + value);
}).call(this);
次に、*コマンドプロンプト*を再度開き、以下に示すようにCoffeeScriptファイルを実行します。
c:\> coffee math_ceil.coffee
CoffeeScriptファイルを実行すると、次の出力が生成されます。
The ceil value of 90.15 is : 91
The ceil value of 15.90 is : 16
The ceil value of -90.15 is : -90
The ceil value of -15.90 is : -15