如何在Watson Conversation中将表达式输出限制为2个小数位?

问题描述 投票:1回答:1

我在Watson Conversation中的对话节点中正确使用以下表达式,其中表达式用于对用户的响应:

<? ($total_balance * $acceptable_offer) ?>

我需要将输出限制为2位小数。我尝试以下列格式将toFixed(2)附加到表达式,但它不起作用:

<? ($total_balance * $acceptable_offer).toFixed(2) ?>

如何编辑表达式,以便只用2位数正确显示结果?

ibm-watson watson-conversation
1个回答
1
投票

使用方法:

<? T(Math).round($total_balance * $acceptable_offer * 100.00)/100.00?>

T(Math)是Watson会话中用于执行简单数学运算的新功能。

© www.soinside.com 2019 - 2024. All rights reserved.