Curl Global Community

Full Version: BigDecimal -> int
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
お世話になっています。

BigDecimal の項目を合計して int の値として出力しようとしています。
String を経由して変換する方法を取っていますが、
もし他によく使われている方法があればご教示ください。

今は大体下記のような感じにしています。
Code:
let total:BigDecimal = {BigDecimal.from-double 0.0}
{for bd in bd-array do
        {total.add bd}
}
{return {{{total.set-scale 0}.to-String}.to-int}}

よろしくお願いします。
「整数部」みたいな取り方ができればいいですけどね。
to-String を挟まなくても、スケール設定したならto-doubleでもよいかも。

Code:
{def i = {total.set-scale 0}}
{value {i.to-double} asa int}