Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Rounding up based on a decimal value

I would like to be able to round a number based on a decimal value. For
example, if the result is 23.7, 23.8, or 23.9, I want the number to round up
to 24. I always want to round up for .7 and higher.
Is there a way to code this?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 427
Default Rounding up based on a decimal value

add 0.3, and rounddown
23.6 would be 23.9 - 23
23.7 would be 24.0 - 24
23.8 would be 24.1 - 24

so if values in a2,a3 etc b2=rounddown(a2+0.3)

Steve

On Mon, 27 Nov 2006 16:55:02 -0000, Kelley
wrote:

I would like to be able to round a number based on a decimal value. For
example, if the result is 23.7, 23.8, or 23.9, I want the number to
round up
to 24. I always want to round up for .7 and higher.
Is there a way to code this?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Rounding up based on a decimal value

Thanks. If the result is .0, .1, .2, .3, .4, .5, or .6, I need the decimal
to stay. If the result is .7, I need it to round up to the nearest integer.
It the result is .8, or .9, I need it to round to .1 or .2.

"SteveW" wrote:

add 0.3, and rounddown
23.6 would be 23.9 - 23
23.7 would be 24.0 - 24
23.8 would be 24.1 - 24

so if values in a2,a3 etc b2=rounddown(a2+0.3)

Steve

On Mon, 27 Nov 2006 16:55:02 -0000, Kelley
wrote:

I would like to be able to round a number based on a decimal value. For
example, if the result is 23.7, 23.8, or 23.9, I want the number to
round up
to 24. I always want to round up for .7 and higher.
Is there a way to code this?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 427
Default Rounding up based on a decimal value

That's not what you said the first time :)

a2 has value
b2 = if((int(a2)-a2)<0.7,a2,a2+0.3)

Steve


On Mon, 27 Nov 2006 18:16:01 -0000, Kelley
wrote:

Thanks. If the result is .0, .1, .2, .3, .4, .5, or .6, I need the
decimal
to stay. If the result is .7, I need it to round up to the nearest
integer.
It the result is .8, or .9, I need it to round to .1 or .2.

"SteveW" wrote:

add 0.3, and rounddown
23.6 would be 23.9 - 23
23.7 would be 24.0 - 24
23.8 would be 24.1 - 24

so if values in a2,a3 etc b2=rounddown(a2+0.3)

Steve

On Mon, 27 Nov 2006 16:55:02 -0000, Kelley
wrote:

I would like to be able to round a number based on a decimal value.

For
example, if the result is 23.7, 23.8, or 23.9, I want the number to
round up
to 24. I always want to round up for .7 and higher.
Is there a way to code this?





--
Steve (3)
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 837
Default Rounding up based on a decimal value

I think you meant =IF((A2-INT(A2))<0.7,A2,A2+0.3) which presumes that A20.

Also, You need to be a bit more careful about the impact of finite precision
binary representations. For instance, if A2 contains 8.7, then
((A2-INT(A2))<0.7 is TRUE.

Jerry

"SteveW" wrote:

That's not what you said the first time :)

a2 has value
b2 = if((int(a2)-a2)<0.7,a2,a2+0.3)

Steve


On Mon, 27 Nov 2006 18:16:01 -0000, Kelley
wrote:

Thanks. If the result is .0, .1, .2, .3, .4, .5, or .6, I need the
decimal
to stay. If the result is .7, I need it to round up to the nearest
integer.
It the result is .8, or .9, I need it to round to .1 or .2.

"SteveW" wrote:

add 0.3, and rounddown
23.6 would be 23.9 - 23
23.7 would be 24.0 - 24
23.8 would be 24.1 - 24

so if values in a2,a3 etc b2=rounddown(a2+0.3)

Steve

On Mon, 27 Nov 2006 16:55:02 -0000, Kelley
wrote:

I would like to be able to round a number based on a decimal value.
For
example, if the result is 23.7, 23.8, or 23.9, I want the number to
round up
to 24. I always want to round up for .7 and higher.
Is there a way to code this?




--
Steve (3)



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 20
Default Rounding up based on a decimal value

Thanks to both of you for your help. Using Steve's response, I was able to
figure out Jerry's solution yesterday. I also changed the 0.7 to <0.6666 and
it works.
Thanks again.

"Jerry W. Lewis" wrote:

I think you meant =IF((A2-INT(A2))<0.7,A2,A2+0.3) which presumes that A20.

Also, You need to be a bit more careful about the impact of finite precision
binary representations. For instance, if A2 contains 8.7, then
((A2-INT(A2))<0.7 is TRUE.

Jerry

"SteveW" wrote:

That's not what you said the first time :)

a2 has value
b2 = if((int(a2)-a2)<0.7,a2,a2+0.3)

Steve


On Mon, 27 Nov 2006 18:16:01 -0000, Kelley
wrote:

Thanks. If the result is .0, .1, .2, .3, .4, .5, or .6, I need the
decimal
to stay. If the result is .7, I need it to round up to the nearest
integer.
It the result is .8, or .9, I need it to round to .1 or .2.

"SteveW" wrote:

add 0.3, and rounddown
23.6 would be 23.9 - 23
23.7 would be 24.0 - 24
23.8 would be 24.1 - 24

so if values in a2,a3 etc b2=rounddown(a2+0.3)

Steve

On Mon, 27 Nov 2006 16:55:02 -0000, Kelley
wrote:

I would like to be able to round a number based on a decimal value.
For
example, if the result is 23.7, 23.8, or 23.9, I want the number to
round up
to 24. I always want to round up for .7 and higher.
Is there a way to code this?




--
Steve (3)

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 427
Default Rounding up based on a decimal value

Ta for the feedback.

Excel is pretty accurate, but all floating point stuff needs care.

If 0.6666 covers the data that you are working with thats the best way.

Steve


On Tue, 28 Nov 2006 18:54:03 -0000, Kelley
wrote:

Thanks to both of you for your help. Using Steve's response, I was able
to
figure out Jerry's solution yesterday. I also changed the 0.7 to
<0.6666 and
it works.
Thanks again.

"Jerry W. Lewis" wrote:

I think you meant =IF((A2-INT(A2))<0.7,A2,A2+0.3) which presumes
that A20.

Also, You need to be a bit more careful about the impact of finite
precision
binary representations. For instance, if A2 contains 8.7, then
((A2-INT(A2))<0.7 is TRUE.

Jerry

"SteveW" wrote:

That's not what you said the first time :)

a2 has value
b2 = if((int(a2)-a2)<0.7,a2,a2+0.3)

Steve


On Mon, 27 Nov 2006 18:16:01 -0000, Kelley
wrote:

Thanks. If the result is .0, .1, .2, .3, .4, .5, or .6, I need the
decimal
to stay. If the result is .7, I need it to round up to the nearest
integer.
It the result is .8, or .9, I need it to round to .1 or .2.

"SteveW" wrote:

add 0.3, and rounddown
23.6 would be 23.9 - 23
23.7 would be 24.0 - 24
23.8 would be 24.1 - 24

so if values in a2,a3 etc b2=rounddown(a2+0.3)

Steve

On Mon, 27 Nov 2006 16:55:02 -0000, Kelley
wrote:

I would like to be able to round a number based on a decimal

value.
For
example, if the result is 23.7, 23.8, or 23.9, I want the number

to
round up
to 24. I always want to round up for .7 and higher.
Is there a way to code this?

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
Decimal Rounding Urgent Excel Discussion (Misc queries) 4 November 26th 08 08:24 PM
Rounding up for a decimal Sena Excel Worksheet Functions 4 July 9th 07 07:29 AM
Rounding to two even decimal places needhelp Excel Worksheet Functions 3 May 16th 07 12:49 AM
Rounding off decimal places Clay64 Excel Discussion (Misc queries) 7 March 29th 07 10:30 PM
Rounding decimal Sturart Excel Worksheet Functions 1 February 16th 06 07:06 PM


All times are GMT +1. The time now is 04:27 AM.

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

About Us

"It's about Microsoft Excel"