Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Round a number away from zero
ResourceFunction["RoundAwayFromZero"][n] rounds n away from 0. | |
ResourceFunction["RoundAwayFromZero"][n,a] rounds n away from 0 to a multiple of a. |
Round a number:
| In[1]:= |
| Out[1]= |
Round a negative number:
| In[2]:= |
| Out[2]= |
RoundAwayFromZero is Listable:
| In[3]:= |
| Out[3]= |
Round 'outwards' to a multiple of 0.25:
| In[4]:= |
| Out[4]= |
The opposite (rounding towards zero) can be achieved using IntegerPart:
| In[5]:= | ![]() |
| Out[5]= | ![]() |
Plot values after rounding:
| In[6]:= |
| Out[6]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License