Round in codeless

Hi
how can i round float to the first decimal?
for example 12.215544785
i want it to be 12.2
like Number.toFixed() in js

Hi @mohammad_altoiher,

Please see below:

i did try that but it return to 12 not 12.2

what about multiple it by 10 then round and finally divide it by 10?

i will try that
it seems a lot of work tho.
it will be nice to implement the toFixed function if possible in the future

Is there still no native way to do decimals rounding, preferably with a given number of decimals to round to, in Backendless @vladimir-upirov ?

Asking since this is an old message, but I cannot find a direct solution without using custom code blocks or more creative math like you suggested here.

I have created my own little function do do this for me. Sharing here in case it will help someone else:

1 Like

Hello @Egil_Helland

Yes, there is no such block.
However, you can actually use raw code or your own little function to achieve this goal.

Regards,
Vladimir

1 Like

Thanks Egil.

@vladimir-upirov - this seems to work pretty well. I’m not experienced enough to comment on whether it’s the best way but it does seem like rounding to a specific decimal place is a basic math function that is needed quite often. It might be worth just making this function of Egil’s available natively if that’s an option in the short term.

Hello @mohammad_altoiher @James_Hereford @Egil_Helland


We’ve added a Codeless block to format the number.
This is available in version 7.0.16.2.

Regards,
Inna

Thanks!