The El expression is an integer or a fixed decimal number.

Source: Internet
Author: User

The division result of El expression is float.
For example, $ {8/7}, $ {6/7}, and $ {12/7} are displayed on the page as follows:
1.1428571428571428
0.8571428571428571
1.7142857142857142

Now, my goal is to only take the preceding integer. Now I use the <FMT: formatnumber/> label of the El expression, for example:
<FMT: formatnumber type = "Number" value = "$ {8/7)}" maxfractiondigits = "0"/>
The result is 1.
Maxfractiondigits = "0" indicates to retain 0 decimal places, that is, to take an integer. Note: The integer is rounded to the nearest integer.
If the result of $ {1/7} is 0 and the result of $ {6/7} is 1, this method is suitable for rounding.
Of course, to retain a fixed decimal point, you only need to modify the 0 in maxfractiondigits = "0" and change the number of digits after the decimal point.

Of course, there are also methods for rounding.
For example:
<FMT: formatnumber type = "Number" value = "$ {13-13% 7)/7)}"/>
If the result of the above method is 2, the result of this method is 1, which is obtained for different purposes.
In fact, the remainder is obtained first, and the remainder is subtracted and then divided. In this way, the result is an integer, so there is no problem of rounding. Because after the remainder is subtracted, the Division is completed. After my test, maxfractiondigits = "0" does not work anymore.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.