How to round a value In Excel - 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

Related

Function that returns number of significant figures after decimal point in specific formatting

Wondering if anyone knows a function that would return the number of significant figures after a decimal point? And even further how to put that number in a specific formatting?
For example if the number was 27.9834 it would return 0.0001. Or if it was 2.1 it would return 0.1.
You should be able to do this using a LEN and MATCH to get the number of decimal points, then its a simple "^" function to get the decimal place.
Assuming your number is in Cell A1:
=10^-(LEN(A1) - FIND(".",A1))
Just make sure you are showing the right number of significant digits in the result cell or it will just look like zero.
The LEN() counts the number of characters and then you subtract the number of characters from the left to where the decimal is. I think there is an upper limit on the number of decimals that excel can handle, but i don't recall what it is.
Another method might be,
=AGGREGATE(14, 6, POWER(10, -(ROW($1:$16)-1))/(TRUNC(A2, ROW($1:$16)-1)=A2), 1)

Convert decimal to whole number - but ignoring value

I know how to isolate the decimal using the TRUNC() function, as well as taking the original value and subtracting this truncated part.
And I can then multiply to get whole number.
But that only works if all my decimals are the same place. I want something that will get me the amount after the decimal point as a whole number, regardless of how many places.
eg: 12.2 would return 2
12.21 would return 21
With data in A1, consider:
=IF(ISERROR(FIND(".",A1)),A1,--MID(A1,(FIND(".",A1)+1),9999))
Naturally leading zeros in the output are dropped:

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.

Rounding Decimals to 0, 5, 1

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:

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