Jump to content
  • Advertisement
Sign in to follow this  
nife

float and double

This topic is 5410 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I know that a f or d after a number declares it as a float or a double, but how about 0.0 compared to 0.0f or 0.0d? I just want to know how the compiler (GCC) treats floating point numbers without an 'extension'.

Share this post


Link to post
Share on other sites
Advertisement
*deleted misinformation*

#include <iostream>
void it_is( float ) { std::cout << "It is a float" << std::endl; }
void it_is( double) { std::cout << "It is a double"<< std::endl; }
int main ( int argc , char ** argv )
{
std::cout << "What is 0.0? "; it_is( 0.0 );
std::cout << "What is 0.0f? "; it_is( 0.0f );
std::cout << "What is 0.0d? "; it_is( 0.0d ); //main.cc:8:43: invalid suffix "d" on floating constant
}


[Edited by - MaulingMonkey on September 25, 2004 5:02:22 AM]

Share this post


Link to post
Share on other sites
Quote:
Original post by nife
Hi, I know that a f or d after a number declares it as a float or a double, but how about 0.0 compared to 0.0f or 0.0d?
I just want to know how the compiler (GCC) treats floating point numbers without an 'extension'.


Using a d in that context doesn't make sense, it only works with f to make a float. To mean a double, just use the 0.0 (or just 0.) without anything else (yes, it will always be a double, it's not compiler dependent).

Share this post


Link to post
Share on other sites
Quote:
only works with f to make a float. To mean a double, just use the 0.0 (or just 0.) without anything else (yes, it will always be a double, it's not compiler dependent).


Sorry, I just thought I remembered something about a 0.0d, therefore I just tried it, and of course it dídn't work...
And again, sorry, this time for posting without even giving it a try... I must stop relying on my memory ;)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!