How can I round a number to 2 significant figures

  • Thread starter Glen in Australia
  • Start date
G

Glen in Australia

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
 
B

bcap

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top