- Local time
- Today, 17:38
- Joined
- Feb 28, 2001
- Messages
- 31,044
When exactly is a constant better than a variable?
Depends on your level of caution and/or confidence in your typing. For instance, in some of my hobbyist writing I have fantasy novels. In them I am doing some totally unnecessary - but fun - computations of lunar orbits for a fantasy world with multiple moons of differing periods. In that computation I often need the value of PI. If I declare a global value of
PUBLIC CONST PI AS DOUBLE = 3.141592653589793
it is a lot easier to type 2 letters rather than 16 digits and a decimal point.
If you needed Euler's constant or Avogadro's number or Planck's constant or the speed of light, would you rather type a short name or the long numbers?