Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Mikus
 
Posts: n/a
Default Round function that rounds down if 5

Is it possible to construct function that rounds down if 5 is met

For example:
1) 2.455 = 2.45
2) 2.454 = 2.45
3) 2.456 = 2.46

ROUND function (num_digits = 2) does following
1) 2.455 = 2.46
2) 2.454 = 2.45

ROUNDUP function (num_digits = 2) does following
1) 2.455 = 2.46
2) 2.454 = 2.46
  #2   Report Post  
Harlan Grove
 
Posts: n/a
Default

Mikus wrote...
Is it possible to construct function that rounds down if 5 is met

For example:
1) 2.455 = 2.45
2) 2.454 = 2.45
3) 2.456 = 2.46

....

Simplest way would be

=ROUND(x-0.0009,2)

  #3   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On Mon, 29 Aug 2005 08:50:10 -0700, "Mikus"
wrote:

Is it possible to construct function that rounds down if 5 is met

For example:
1) 2.455 = 2.45
2) 2.454 = 2.45
3) 2.456 = 2.46

ROUND function (num_digits = 2) does following
1) 2.455 = 2.46
2) 2.454 = 2.45

ROUNDUP function (num_digits = 2) does following
1) 2.455 = 2.46
2) 2.454 = 2.46


I believe this formula will do what you describe:

=IF(MOD(INT(A1*10^(NumDigits+1)),10^(NumDigits-1))<=5,
ROUNDDOWN(A1,NumDigits),ROUND(A1,NumDigits))


--ron
  #4   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On 29 Aug 2005 09:33:26 -0700, "Harlan Grove" wrote:

Mikus wrote...
Is it possible to construct function that rounds down if 5 is met

For example:
1) 2.455 = 2.45
2) 2.454 = 2.45
3) 2.456 = 2.46

...

Simplest way would be

=ROUND(x-0.0009,2)


Given OP's specifications, how should

2.4559

round?


--ron
  #5   Report Post  
Harlan Grove
 
Posts: n/a
Default

Ron Rosenfeld wrote...
On 29 Aug 2005 09:33:26 -0700, "Harlan Grove" wrote:
Mikus wrote...
Is it possible to construct function that rounds down if 5 is met

For example:
1) 2.455 = 2.45
2) 2.454 = 2.45
3) 2.456 = 2.46

...

Simplest way would be

=ROUND(x-0.0009,2)


Given OP's specifications, how should

2.4559

round?


Either we read nothing more into the OP's specs, in which case they're
silent about this, so it's up to the OP to decide, or we make an
intelligent extension to the OP's specs. The problem is rounding
numbers to 2 decimal places when the 3rd decimal place is 5 and,
presumably, all subsequent decimal places are zero (that's the
intelligent extension). If there were additional decimal places, then
the 4th decimal place may explicitly be something other than zero. If
so, use

=ROUND(ROUND(x,3)-0.0009,2)

The inner ROUND call would return 2.456 given 2.4559, and the outer
ROUND call would return 2.46, which I'd guess is what the OP would
want.

You'd have done better to have used 2.4558.



  #6   Report Post  
Ron Rosenfeld
 
Posts: n/a
Default

On 29 Aug 2005 11:07:53 -0700, "Harlan Grove" wrote:

Ron Rosenfeld wrote...
On 29 Aug 2005 09:33:26 -0700, "Harlan Grove" wrote:
Mikus wrote...
Is it possible to construct function that rounds down if 5 is met

For example:
1) 2.455 = 2.45
2) 2.454 = 2.45
3) 2.456 = 2.46
...

Simplest way would be

=ROUND(x-0.0009,2)


Given OP's specifications, how should

2.4559

round?


Either we read nothing more into the OP's specs, in which case they're
silent about this, so it's up to the OP to decide, or we make an
intelligent extension to the OP's specs. The problem is rounding
numbers to 2 decimal places when the 3rd decimal place is 5 and,
presumably, all subsequent decimal places are zero (that's the
intelligent extension). If there were additional decimal places, then
the 4th decimal place may explicitly be something other than zero. If
so, use

=ROUND(ROUND(x,3)-0.0009,2)

The inner ROUND call would return 2.456 given 2.4559, and the outer
ROUND call would return 2.46, which I'd guess is what the OP would
want.

You'd have done better to have used 2.4558.


Well, I didn't know. We made different assumptions, and came up with different
results.

I would think it equally "intelligent" (or not) to make the assumption that
subsequent decimal places are undefined, and hence could be anything. But
YMMV.

It might be important if the numbers are a result of a formula, rather than
direct entry, though.


--ron
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Round a number in nested function kim Excel Worksheet Functions 1 July 6th 05 11:45 AM
The ROUND function Louise Excel Worksheet Functions 3 June 23rd 05 02:45 PM
Excel option to store trendline's coefficients in cells for use Miguel Saldana Charts and Charting in Excel 9 June 20th 05 08:45 PM
round function in excel 2000 lots of questions Excel Worksheet Functions 2 March 4th 05 01:41 AM
help with round function Scott Excel Worksheet Functions 7 February 9th 05 07:23 PM


All times are GMT +1. The time now is 03:54 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"