Tilted Forum Project - TFP - Sexuality, Philosophy and Political Discussion

Go Back   Tilted Forum Project - TFP - Sexuality, Philosophy and Political Discussion > Interests > Tilted Technology

Reply
 
LinkBack Thread Tools
Old 02-16-2005, 08:55 PM   #1 (permalink)
Insane
 
Join Date: Apr 2003
Location: Magic hole of no exciting weather
[c++] symbolic constants

I'm having trouble figuring out how to represent the value of pi in two different ways using symbolic constants. The book is giving me no useful info. Could I get some help? Thanks.
__________________
CUBS WIN, CUBS WIN!!!! - Pat Hughes
"Don't surround yourself with yourself." Yes
Locke is offline   Reply With Quote
Old 02-16-2005, 09:09 PM   #2 (permalink)
Insane
 
Join Date: Apr 2003
Symbolic constants are just defines.

So #define PI 3.14 is one way to represent PI
username is offline   Reply With Quote
Old 02-16-2005, 09:29 PM   #3 (permalink)
Insane
 
Join Date: Apr 2003
Location: Magic hole of no exciting weather
hey thanks. Could I also do something like: Const PI = 3.14 as the second way. Or can I just do #define PI 3.1415?
__________________
CUBS WIN, CUBS WIN!!!! - Pat Hughes
"Don't surround yourself with yourself." Yes
Locke is offline   Reply With Quote
Old 02-16-2005, 09:48 PM   #4 (permalink)
Insane
 
Join Date: Apr 2003
#define PI 3.1415 is the same method as #define PI 3.14 and Const PI = 3.14 wouldn't be a symbolic constant. Think about what #define does. It replaces the token PI in the source code with the number 3.14 before the code is compiled. Using this idea, a #define could be more than a number...
username is offline   Reply With Quote
Old 02-16-2005, 10:34 PM   #5 (permalink)
Rookie
 
Join Date: Jun 2003
Location: Waterloo
Keep in mind though that if you are using the term const, you need a type, it would be

const double PI = 3.14
__________________
Everyone on the Universal Serial Bus!
Molo is offline   Reply With Quote
Reply

Bookmarks

Tags
constants, symbolic

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


All times are GMT -7. The time now is 02:09 PM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
All text (c) 2002-2008 Tilted Forum Project
"Insignia" vBulletin 3.5 - b6gm6n - x7x7x7.com