【问题标题】:How to truncate a number如何截断一个数字
【发布时间】:2020-08-28 09:37:01
【问题描述】:

我应该在表格中显示数字。但我需要该数字在逗号后只有两个字符。如何正确地做到这一点。

            $score =  $schet;
%>
            <tr class="ten" >
                <td class="six" > <%= $schet %></td>
                <td> <%= $d->start %></td>
                <td> <%= $d->end   %></td>
            </tr>
<%
        }

【问题讨论】:

    标签: html perl numbers decimal truncate


    【解决方案1】:

    使用sprintf:

    my $number_with_two_decimal_places = sprintf '%.2f', $float;
    

    【讨论】:

    • 谢谢!这是我需要的结果 overall_start_debet ) %>
    猜你喜欢
    • 2018-11-27
    • 2018-04-12
    • 1970-01-01
    • 2015-11-11
    • 1970-01-01
    • 2021-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多