LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #9   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.excel.worksheet.functions,microsoft.public.excel
external usenet poster
 
Posts: 837
Default How many decimal places can a cell display?

While better than xl97 (as Tom showed), formatting as a fraction is still not
entirely reliable when you request many digits. The DP (IEEE double
precision) approximation to Pi is exactly
884279719003555/281474976710656
which has a 15 digit denominator. However, you get the same value as the DP
approximation to
245850922/78256779
which only has an 8 digit denominator.

Jerry

"Dana DeLouis" wrote:

If you want to do a program loop, this is one of a few ways to get a jump
start...

Sub Demo()
Dim s As String
s = WorksheetFunction.Rept("?", 16)
s = s & "/" & s

Range("A1").FormulaR1C1 = "=PI()"
Range("A1").NumberFormat = s
Debug.Print Range("A1").Text
End Sub

5419351/1725033

As you can see, the fraction format can get close(~14), but not quite...:(
--
HTH. :)
Dana DeLouis
Windows XP, Office 2003


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






 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell Swallows Decimal Places [email protected] Excel Discussion (Misc queries) 5 August 28th 07 02:17 PM
appended a cell, but need to keep decimal places [email protected] Excel Discussion (Misc queries) 2 April 11th 07 10:31 PM
decimal places in format cell tom Excel Discussion (Misc queries) 2 February 16th 07 09:07 PM
How many decimal places can a cell display? Spaz Excel Worksheet Functions 10 April 3rd 06 08:33 PM
Formatting a cell to display varying decimal places. JayE Excel Programming 8 May 21st 05 11:35 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"