Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I round a number to 2 significant figures

926 views
Skip to first unread message

Glen in Australia

unread,
Aug 8, 2008, 2:56:01 AM8/8/08
to
IN an Access report - Why can't I - or better still HOW CAN I - convert a
number in a field to show as - say - 2 significant figures - the ROUND()
function only does it to decimal places - Why can't I use the code that is
used in Excel i.e. =ROUND(A2,3-LEN(INT(A2))) to give me a figure with 2
significant figures !!! that is if A2 = 5492820 I get 5500000.

This is so important in my laboratory reporting program !
Many thanks
--
Glen
Simple Scientist aka Microbiologist
Brisbane
Australia

Allen Browne

unread,
Aug 8, 2008, 3:41:48 AM8/8/08
to
See:
http://allenbrowne.com/round.html#RoundNegativePlaces

The article provides a couple of alternatives: an alternative formula, or a
custom rounding function.

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"Glen in Australia" <GleninA...@discussions.microsoft.com> wrote in
message
news:F3C7F6B8-2B9E-4467...@microsoft.com...

bcap

unread,
Aug 8, 2008, 4:12:15 AM8/8/08
to
Why can't you? Because Access isn't Excel.

How can you? Well, a brief Google turned this up:

Public Function FormatSigFig(Value As Double, SigFigs As Long) As String
Dim RoundedValue As Double
Dim Digits As Long
Digits = SigFigs - Int(Log(Abs(Value)) / Log(10)) - 1
FormatSigFig = Int(0.5 + Value * 10 ^ Digits) / 10 ^ Digits
End Function

Seems to work, although I haven't given it much of a test.

If you are ever inclined to use the Access Round function, you should be
aware that it does bankers' rounding, not arithmetical rounding.


"Glen in Australia" <GleninA...@discussions.microsoft.com> wrote in
message news:F3C7F6B8-2B9E-4467...@microsoft.com...

0 new messages