Solved

Rounding Decimals

Posted on 2000-03-03
4
495 Views
Last Modified: 2012-08-14
Fairly important to what I'm doing right now . . . .Is there a function that rounds decimals correctly, as Cint() rounds numbers x.5 to the nearest even number and Int() truncates them.

Thanks
0
Comment
Question by:G_Thompson
4 Comments
 
LVL 10

Accepted Solution

by:
paasky earned 50 total points
ID: 2579493
Hello G_Thompson,

I think you can find the suitable function for you from this URL:

http://www.experts-exchange.com/jsp/qShow.jsp?ta=msaccess&qid=10300683 

regards,
Paasky
0
 
LVL 7

Expert Comment

by:Dedushka
ID: 2579691
In Acc2000 there is a new function Round(<number>,<precision>), but in online help it is not described. You can find it in object browser.
0
 
LVL 4

Expert Comment

by:wesleystewart
ID: 2579741
This is a good rounding function:

http://www.mvps.org/access/modules/mdl0054.htm

Wes
0
 

Author Comment

by:G_Thompson
ID: 2580415
Thank you all for your comments I'm not currently using Acces200 unfortunatly,

I altered one of the functions from a previous answer

Function Round(ToRound As Double) As Double
Dim Multiplier As Double
Dim DecimalP As Integer

DecimalP = 0
If (CInt(ToRound)) Mod 2 = 0 Then ToRound = ToRound + 0.1

Multiplier = 10 ^ DecimalP
Round = CLng(ToRound * Multiplier) / Multiplier
End Function

with out the 0.1 added to even numbers rounding 2.5 gave 2 with the addition of 0.1 it gives 3, correct

because the 0.1  is only added to even no's itdoes not affect other results .

I have just realised i could use

Function Round(value as double)

if cint(value)mod 2 <> 0 then
   round = cint(value+0.1)
Else
  round = cint(value)
endif

end function

For rounding to 0 dp

Thanks anyway

G Thompson
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question