%function removeTrailingZeros (numberWithTrailingZeros) (
numberWithTrailingZeros as :string {format: "#.#############################################"} as :number
)
Please refer to the attached project which demonstrates how to achieve that.{
"TrailingZerosNumber": 10.165000000000000000000,
"TrailingZerosNegativeNumber": -10.1650000000000000000000,
"NoTrailingZerosNumber": 10.165,
"NoTrailingZerosNegativeNumber": -10.165
}
So it represents all possible use cases in removing trailing zeros.curl -i -H "content-type: application/json" -X POST -d '{ "TrailingZerosNumber": 10.165000000000000000000, "TrailingZerosNegativeNumber": -10.1650000000000000000000, "NoTrailingZerosNumber": 10.165, "NoTrailingZerosNegativeNumber": -10.165 }' http://localhost:8081/trailing
The output looks similar to the below:
HTTP/1.1 200
Transfer-Encoding: chunked
MULE_ENCODING: UTF-8
Content-Type: application/json
Date: Fri, 13 Apr 2018 03:51:41 GMT
{
"ProcessedTrailingZerosNumber": 10.165,
"ProcessedTrailingZerosNegativeNumber": -10.165,
"ProcessedNoTrailingZerosNumber": 10.165,
"ProcessedNoTrailingZerosNegativeNumber": -10.165
}
To ensure the solution works for a particular case, it is recommended to give a try to different trailing zero numbers before continuing. 001114983

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.