Thread: Syntax Error!
View Single Post
  #11   Spotlight this post!  
Unread 04-02-2006, 14:42
CronosPrime1 CronosPrime1 is offline
Registered User
FRC #0321
 
Join Date: Jan 2006
Location: Hyperspace
Posts: 53
CronosPrime1 is an unknown quantity at this point
Re: Syntax Error!

That indicates that the numbers are floats.

I suppose the reason why it's needed is that the computer always needs to know what data type everything is. So in a normal variable declaration, you say something like

float distance;

This tells the computer or FRC controller that you are declaring a variable of type float, and the processor allocates a specific number of bytes to that variable. It's usually 4 bytes to a float. Since the memory allocation must be done before doing anything with the variable, variables must be declared before they are used, and they need to be declared as being a specific type because different types are allocated different amounts of memory.

In a macro, there is no keyword float. Thus, you need some sort of indicator showing of what type the constant or whatever is. Whoever made C decided that in a macro "f" would suffice for this purpose.

#define PI 3.14159265f
__________________

Last edited by CronosPrime1 : 04-02-2006 at 14:52.