铸造int漂浮在百里香前端 [英] Casting int to float in thymeleaf frontend

查看:70
本文介绍了铸造int漂浮在百里香前端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的东西:

<span th:text="*{a / (b + c)}"></span>

其中a,b和c为整数。我需要将结果作为浮点数。

where a, b and c are integers. I need the result to be a floating point number.

有什么想法吗?

实际代码:

<span th:text="(*{item.candidates } > 0 and *{item.budgetSeats + item.taxSeats} > 0)?*{#numbers.formatDecimal(item.candidates / (item.budgetSeats + item.taxSeats),1,2, 'POINT')}:'N/A'">


推荐答案

答案很简单:

用浮点数乘(至少)一个数字,例如 1.0

Multiply (at least) one of the numbers with a float e.g. 1.0.

<span th:text="*{ (a * 1.0) / (b + c)}"></span> 

这篇关于铸造int漂浮在百里香前端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆