Round a decimal number
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 03:19 PM
I having a problem rounding a number to a certain precision ....
I gettting a value as a string from a form field , then I convert that number to a foat and then applied the round function.... but it does not work as I want it...
var temp = parseFloat(g_form.getValue('substance_allowance'));
temp = Math.round(temp).toFixed(2); it wont work to rund the value two decimals places if a situation applies.... what it does it rounds up but it moves the decimals two places to the right.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 03:23 PM
You want to round the figure or want to convert to 2 decimal?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 08:27 PM
I want round any length whole number which it shouldn't be affected containing a fractional part greater than two decimals to this precision rounded up.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 03:31 PM
can we try like.
var temp = Math.round(parseFloat(g_form.getValue('substance_allowance')));
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-17-2017 08:26 PM
This rounds to the nearest whole number...... I want to hold to 2 decimals places and rounded.