joeu2004 wrote:
"Auric__" wrote:
I just assign it to a constant if I need it:
Const PI = 3.14159265358979
If you want to ensure a match with Excel PI(), use the following
constant expression:
Const pi As Double = 3.14159265358979 + 3.1E-15
Or you could write:
Const pi As Double = "3.1415926535897931"
The internet says that last digit should be 2. Shrug.
http://oeis.org/A000796
since VBA converts all digits, not just the first 15 significant digits
as Excel does.
FYI, I avoid writing the following:
Const pi As Double = 3.1415926535897931
It works initially. But VBA displays the statement as
Const pi As Double = 3.14159265358979
and the value of pi will be changed to 3.14159265358979 if we edit the
line (e.g. append a comment) and perhaps under other conditions that
cause VBA to re-interpret the statement.
To confirm the differences, try the following macro.
[snip]
On the one hand, if I ever needed more precision than I posted, I would be
likely to go nuts:
Const PI = "3.14159265358979323846264338327950288419716939937 510582097494"
On the other hand, I don't think I've *ever* needed more than about 4 or 5
digits. My programs aren't mathematical or scientific (accounting, yes, but
my numbers don't involve circles) and the graphical toys I've written don't
need that much precision, not by a long shot. ;-)
--
I just checked your horoscope.
It recommends you not be alive for the next month.