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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|