How round the value after two decimal point
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2019 01:11 AM
We have a filed in our catalog item name Price. If the enter value 10.98723 it should round to 10.99. How to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2019 03:08 AM
Please refer below:
var x= parseFloat(current.u_field);
x= x.toFixed(2);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-27-2019 03:22 AM
Hello,
Do you have an example of the script your using?
For example in this calculated field you normally just add toFixed(2) the line and it rounds it.
(function calculatedFieldValue(current) {
var total = (current.u_test1 + current.u_test_2).toFixed(2);
return total;
})(current);
Please mark as helpful or if its resolved it mark as correct!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-09-2022 10:16 AM
Hello Andrew,
it helped me when the results return more than two decimals, but when this number it's zero doesn't work. it's ignoring the number zero.
For example:
Case 1 - Ex: If it's 10,987 it's transformed in 10,99 [Behavior it's OK]
Case 2 - Ex: If it's 10,90 it's transformed in 10,9 instead of 10,90
Case 3 Ex: If it's 10,00 it's transformed in 10 instead of 10,00
But in all cases I need that behavior to be the same as in case 1
How can I fix it ?
Thank you,
Jessy