Rounding Decimals to 0, 5, 1 - excel

Here in Kuwait (Arab country) we used three decimals after comma such as (100.523, 50.978, 340.143, 76.552, 414,081... etc).
How can rounding only the decimals to 0 or 5 or 1, for example:
1. 50.231 rounding to **50.230** Keeping same
2. 50.232 rounding to **50.230**
3. 50.233 rounding to **50.230**
4. 50.234 rounding to **50.230**
5. 50.235 rounding to **50.235** Keeping same
Another type of example for rounding to 1:
1. 50.236 rounding to **50.235**
2. 50.237 rounding to **50.235**
3. 50.238 rounding to **50.235**
4. 50.239 rounding to **50.235**
5. 50.240 rounding to **50.240** Keeping same.
If it possible can solve this issue in excel by using a formula or no?

You seem do be doing a FLOOR operation, not a round. The difference is that floor always rounds downwards, to the precision decided, while ROUND rounds to the nearest, either up or down.
With excel, you can do the following and set the precision:
=FLOOR(A1, 0.005)
For reference, see https://support.office.com/en-sg/article/FLOOR-function-14bb497c-24f2-4e04-b327-b0b4de5a8886
If using ROUND, your examples
3. 50.238 rounding to **50.235**
4. 50.239 rounding to **50.235**
Would instead round to 50.240 since that is the nearest multiple of 0.005.

You can use this:
=FLOOR.MATH(A1, 0.005)
or
=ROUNDDOWN(A1 * 200; 0) / 200

It looks like you are rounding down to the nearest 0.005. For that, try this formula, which gives the results you show in your example:
=ROUNDDOWN(A1/0.005,0)*0.005
Check that the formula also gives your desired results for negative numbers.
The FLOOR function would need to be modified to work for negative numbers in versions of Excel prior to 2010.
EDIT: In your Comment below, you have changed the results for Example 2. It now appears that you want to perform a simple ROUND, unless the value is nn.nn5 (e.g. exactly on the .005 boundary).
It is not clear what level of precision you require for this, and the IEEE standard for double-precision floating point arithmetic allows for a bit of "slop". So you will need to adjust the comparison exponent depending on your desired level of precision.
Here are the results, showing both your original Examples in your Question, and the different set of Examples in your Comment:

Related

Excel rounds up number in one record, rounds down the same number in another

Excel is rounding numbers inconsistently that is causing me issues. When using ROUND(), sometimes it rounds a specific number up, while at other times it rounds the same value down.
I've tried setting Excel to show exact values in settings, but it doesn't change anything.
This is an example of what is happening.
This is the simple formula ROUND((A1-B1)/2,4)
For one record I have the values (.3159 - .3152) which evaluate to .0007 then divide by 2 to get .00035.
For the next record I have the values (.3554 - .3547) which also evaluates to .0007 and divided by 2 results in .00035
So, even though both values are .00035 when I round off to 4 decimal places I am getting .0003 for one and .0004 for another. Same number, rounding to the same number of places, two different results. How can I fix this?
This is an issue with floating point numbers that is inherent and cannot be solved, only avoided.
Try these tests in Excel:
=(0,3159-0,3152)=(0,3554-0,3547) gives you FALSE.
=(0,3159-0,3152)-(0,3554-0,3547) gives you something like 5.55112E-17.
If you cannot accept the differences, you should round already in the middle of the calculation, not only at the end:
=ROUND(0.3159-0.3152,4)=ROUND(0.3554-0.3547,4) is TRUE
=ROUND(0.3159-0.3152,4)-ROUND(0.3554-0.3547,4) is 0
further reading: Is floating point arithmetic stable? and Binary floating point and .NET, by highly regarded Jon Skeet.

Blueprism Rounding Issue

I have a value of €1850.50. I want a calculation to round this to €1851
My formula is
ToNumber(Round(Replace([Item Data.LHC Part Anaes Rate 2019 (No Rounding)],"€","")))
Currently, it is bringing back €1850. It seems to round values of .5 downwards instead of upwards? This issue is only happening when the value is .50
The reason you're seeing this odd behavior is because .NET (the framework Blue Prism is based on) uses Banker's Rounding to perform rounding functions by default. From the linked page:
Bankers Rounding is an algorithm for rounding quantities to integers, in which numbers which are equidistant from the two nearest integers are rounded to the nearest even integer. Thus, 0.5 rounds down to 0; 1.5 rounds up to 2.
Thus, when leveraging the rounding functionality in a typical calculation stage, 0.5 will round to 0.
To counter this implementation of rounding, you can use one of two methods:
Method #1 - Processing of 0.5 as a separate case
Use decision stages to determine whether or not the number you're attempting to round has five tenths at the end. If yes, add another .5 to "round up". If there's any other decimal number, proceed with the rounding as normal.
Method #2 - Custom rounding implementation
Create a new custom object with an action that takes your number as an input. Write a code stage to implement the rounding as you see fit. This SO question body has some good code you can start with.
Why not use the RndUp function instead? Although I would expect .5 to be rounded up as well.
Also, the order of the functions in your code is not correct, you are first rounding and then converting to number. The Round function performs (or tries to) do the conversion automatically.
It could look like this:
RndUp(ToNumber(Replace("€1850.50","€","")))

How to round a value In Excel

I want to round off the value in Excel when the value is greater than 5 after decimal.
For example:
if num= 9.15, result= 9.1
if num= 9.16, result = 9.2
Although your need contradicts the currently valid rounding rules it could be achieved with the following formula:
=TRUNC($A1*10^1+0.4*SIGN($A1))/10^1
The value in A1 can be any decimal value in any length either positive or negative. It will be "rounded" to 1 decimal place. The 10^1 part in the formula leads to rounding to 1 decimal place. Use 10^2 to round to 2 decimal places and so on.
For the second decimal place, I was going to post
=IF(AND(FIND(".",A2&".")=(LEN(A2)-2),RIGHT(A2)="5"),--LEFT(A2,LEN(A2)-1),ROUND(A2,1))
(modified according to #Jasen's comment)
A very simple approach is
=ROUND(A4-10^-10*SIGN(A4),1)
which should be fine up to several places of decimals if you change the number of decimals to round (but will fail because of rounding errors if the numbers are too large).
This also gives good results over a wide range of numbers:-
=ROUND(A2-A2/10^12,1)
To generalise the first one a bit more you could try
=IF(ISNUMBER(FIND(".",A2)),IF(RIGHT(A2)="5",--LEFT(A2,LEN(A2)-1),ROUND(A2,LEN(A2)-FIND(".",A2)-1)),A2)
to round the last decimal place down if it's a 5.
this should do it
=ceil(A1*10-0.5)/10

EXCEL sumproduct formula not counting correctly

I have a formula in EXCEL 2013 that counts values where the decimal point = .16
=SUMPRODUCT(--(MOD(D2:D9,1)=0.16))
so for example 2.16, 15.16 will be a count of 2. However if the value is 32.16 or greater then will not count. This is very weird issue and cannot fathom this out.
You've hit a floating point error¹. The remainder reads as 0.159999999999997, not 0.16. Round it to at least four decimals to get an accurate read.
=SUMPRODUCT(--(ROUND(MOD(D2:D9,1), 4)=0.16))
¹ See 15 digit precision floating point errors and Floating-point arithmetic may give inaccurate results in Excel.

Round up decimals to fractional multiple

I am trying to round up decimals to specific values in the following way:
1. 12.12 ---> 12.25
2. 12.5 ---> 12.5
3. 12.59 ---> 12.75
4. 12.75 ---> 12.75
5. 12.77 ---> 13
So they should be rounded up to the decimals .25, .5 and .75 or integer.
Is there an Excel function which can do this?
Please try:
=ROUNDUP(4*A1,0)/4
Your question uses positive numbers for sample data but there is a primary difference involving how negative numbers are handled by the CEILING function and the ROUNDUP function that should be mentioned.
This has to do with the way that ROUNDUP rounds away from zero and CEILING rounds to the numerically larger¹ number
          
The formulas in C2:D2 are:
=CEILING(A2, 0.25) ◄ C2
=ROUNDUP(A2*4, 0)/4 ◄ D2
Note the differences in the 7th, 9th and 11th rows. This is the difference in how the two functions handle rounding negative numbers. If you wanted the results in column C to follow the values in column D, you would have to use the following for negative numbers.
=CEILING(A2, -0.25) ◄ C2
But that doesn't work properly on positive numbers. While you could write a conditional statement that changed the sign of the significance parameter, it's a lot easier to choose what you want to happen with negative numbers and use either CEILING or ROUNDUP as the case may be.
¹If you get several mathematicians in a room and ask them if -1 is higher, larger or greater than -2, you will start World War III so I'm not going down that rabbit hole. The differences between CEILING and ROUNDUP are probably intended to cover both sides of the argument.
All of this can be related to the ROUNDDOWN function and the FLOOR function as well.
If you are only rounding to a fractional significance and not rounding in one direction or another, the MROUND function is another possibility.

Resources