Explain CONST?

1. Senior Member
Join Date
Dec 1969
Posts
105

## Explain CONST?

Newbie question: I don&#039;t understand what constants are used for. Can someone please explain?

2. Senior Member
Join Date
Dec 1969
Posts
11,334

## You should check the docs for questions

like this.<BR><BR>A const is just a variable that cannot be changed.<BR><BR>They&#039;re useful so you don&#039;t accidentally change a value.

3. Senior Member
Join Date
Dec 1969
Posts
2,930

## hmm...

they aren&#039;t "variables", they are "constants". a good use for a const is something that always has the same value, like Pi<BR><BR>const PI = 3.14159<BR><BR>Dim area<BR>Dim radius<BR><BR>radius = 5.0<BR>area = PI * radius*radius

4. Senior Member
Join Date
Dec 1969
Posts
11,334

## Hair splitter

Variables, whatever... figured it was easier to explain to her.<BR><BR>Isn&#039;t PI already built in? Or is that just C?<BR><BR>Looks like this is gonna be a looooong day :)

5. Senior Member
Join Date
Dec 1969
Posts
16,931

## Considering how....

....perfect he&#039;s being, surely he calculate calculating Pi to a few thousand digits each time around using the trigonometric approximation, and store that....<BR><BR>...it&#039;d be so much more accurate...<BR><BR>:)<BR><BR>Craig.

6. Senior Member
Join Date
Dec 1969
Posts
2,930

## technically

i don&#039;t know about asp, but in the math.h header there is a definition of PI. so, it&#039;s not "built in"... it&#039;s not a specification for every compiler, you can choose to not define PI. be careful of your wording... i know it&#039;s just a technicality, but I&#039;m very picky about things like that... sorry ;-)

7. Senior Member
Join Date
Dec 1969
Posts
2,930

## RE: Considering how....

http://www.ex.ac.uk/cimt/general/pi10000.htm

8. Senior Member
Join Date
Dec 1969
Posts
16,931

## Hey DG....

...started to hate technicalities? :)<BR><BR>Just kidding man. You are right. Unfortunately sometimes these people have just about got their head around what a variable is. Introducing constants in terms of a variable is probably the easiest way.<BR><BR>Craig.

9. Senior Member
Join Date
Dec 1969
Posts
16,931

## LOL!

You got that in your bookmarks?! :)<BR><BR>Craig.

10. Senior Member
Join Date
Dec 1969
Posts
11,334

## True

Sometimes people understand concepts when you put it to them a certain way.<BR><BR>So is it a variable? No, cause you can&#039;t change it, but she knows she can assign it like one now.<BR><BR>Const x = 4<BR><BR>Geez.... ridin&#039; the ol&#039; Ghost this early in the morning...<BR><BR>:)

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•