A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Setting Up & Running Reports
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

How can I round a number to 2 significant figures



 
 
Thread Tools Display Modes
  #1  
Old August 8th, 2008, 07:56 AM posted to microsoft.public.access.reports
Glen in Australia
external usenet poster
 
Posts: 5
Default How can I round a number to 2 significant figures

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
  #2  
Old August 8th, 2008, 08:41 AM posted to microsoft.public.access.reports
Allen Browne
external usenet poster
 
Posts: 11,706
Default How can I round a number to 2 significant figures

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" wrote in
message
...
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


  #3  
Old August 8th, 2008, 09:12 AM posted to microsoft.public.access.reports
bcap[_2_]
external usenet poster
 
Posts: 260
Default How can I round a number to 2 significant figures

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" wrote in
message ...
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



 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 12:41 PM.


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