View Single Post
  #6   Report Post  
Posted to microsoft.public.excel,microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions
Dana DeLouis
 
Posts: n/a
Default How many decimal places can a cell display?

... VBA procedure of finding fractions that will approximate pi to as many
decimal places as Excel will display,


Hi. At 15 digits, I believe the minimum fraction for Pi is:

=80143857/25510582

As a side note, the limit in vba is:
Num = 428224593349304#
Den = 136308121570117#

Debug.Print CDec(Num) / Den
' 3.1415926535897932384626433833

--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


"Spaz" wrote in message
...
How many decimal places can be displayed in a cell? I'm running a brute
force VBA procedure of finding fractions that will approximate pi to as
many decimal places as Excel will display, but I don't know how many
decimal places Excel will display accurately. Anybody know? I guess this
is also a matter of how many decimal places VBA will calculate accurately
as well.

Sub PiFractions()
Dim dividend As Integer, divisor As Integer, quotient As Double
Dim rowpointer As Byte

rowpointer = 1

For dividend = 22 To 10000
For divisor = 7 To dividend \ 3
quotient = dividend / divisor
If quotient 3.14159 And quotient < 3.1416 Then
Cells(rowpointer, 1) = dividend
Cells(rowpointer, 2) = divisor
Cells(rowpointer, 3) = quotient
rowpointer = rowpointer + 1
End If
Next
Next

End Sub