This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

float primitive and its.... crazyness?!?!

 
Andree Charfen
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
haha.. ok...
Maybe I am noone to call Mr.float primitive crazy.. but it seems crazy to me.
Ok... if you have a primitive member var its default is..... 0.0 buut... float... its not a floatating point type... so you cant asign for example 0.5? Why is this?
REGARDS!
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andree,
I would say that in "literal" terms, the default value of a float is actually "0.0f". When you forget to append the "f", it will treat literals as literal double values. And since a double has more bytes than a float, the compiler will generate an error when you attempt to assign "0.5" to it. However, as I mentioned, setting a float the value of "0.5f" will work just fine for you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic