- acpacentertixAsked on August 29, 2015 at 10:57 PM
I need to round up to the nearest $0.25; but the Ceiling function only allows me to round up to the nearest whole number. How can I do this?
This is a re-post of a comment on Form Calculation - Math Function Reference
- JotForm SupportBJoannaAnswered on August 30, 2015 at 04:32 AM
If I understood you correctly you want to round your number to 1 decimal place.
If that is the case inside of Form Calculation widget field, click on Show Advanced options and change Decimal Places in Numerical Results.
I have made sample form with two calculations. First is rounding calculation to two decimals and second to one decimal place.
Here is my form: http://form.jotformpro.com/form/52412169964965?
If I did not understood you correctly please explain in more details what you are trying to achieve and also provide us ID of the form you are working on.
Hope this will help. Let us know if you need further assistance.
- acpacentertixAnswered on September 01, 2015 at 03:17 PM
In my case, I am working with dollar amounts and need to round up to the nearest 25 cents (0.25). Generally, the ceiling function allows setting an increment for rounding (i.e. 1.07 up to 1.25, 2.35 up to 2.50; etc.). I notice that even if I add the code that sets an increment, it is ignored (i.e. ceiling(x,.25)). Is there another solution to set the increment?
Thanks for all your help!
- JotForm SupportBJoannaAnswered on September 01, 2015 at 05:26 PM
You can try to achieve that with Form Calculation - Math Function floor(number) option and setting condition for each value.
then just check with conditions if 0.xy > 0 and 0.xy < 0.25 ===> floor(number) + 0.25
if > 0.25 and < than 0.5 then ===> floor(number) + 0.50
the same logic can then be used for 0.75 and 100
where for 100 it can either use floor(number) + 1
I have made demo form but it only works with numbers less than 1. Here is my demo form:
Feel free to clone it if you want to take closer look to my conditions.
- acpacentertixAnswered on September 03, 2015 at 04:25 PM
Eureka! You've inspired me.
I solved this by calculating the ceiling for 4 times the value and then dividing the result by 4 (e.g. (ceiling(4*x))/4
- BorisAnswered on September 03, 2015 at 09:39 PM
On behalf of my colleague, you are very much welcome!
We are glad to hear about your workaround. I'm sure it will come in handy for other users in the future as well.
Thank you for updating us. Please don't hesitate to contact us again if you need any other assistance with your forms, we will be happy to help.