CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Mar 2008
    Posts
    2

    double is shown as float in size (newbie)

    Hello there codeguru gurus...
    here is my code:
    PHP Code:
    #include <iostream>
    using namespace std;

    double sqrtOfTwo(int counter)
    {
        if (
    counter==0)
            return 
    0;
        else 
        {
            
    counter--;
            return 
    1.0/(2.0+sqrtOfTwo(counter));
        }    
    }

    int main()
    {
        
    cout << rec(10); // doesn't really matter what number comes here
        
    return 0;

    when i run this code the output will be : 0.414214 , which is shorter than what i'd expect to receive, having declared this function as a double, not as a float. this may be something i simply do not understand in the way variable types work. either way, i'd really appreciate details regarding this issue.
    Last edited by dankilman; March 1st, 2008 at 03:46 PM.

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured