Thread: passing arguments by reference - finding integer and fraction parts

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Because there are numbers that fit in a float that don't fit in a long.

  2. #2
    Registered User
    Join Date
    Mar 2011
    Posts
    254
    Quote Originally Posted by tabstop View Post
    Because there are numbers that fit in a float that don't fit in a long.
    Are you alluding to the fact that long has a wide range? But the purpose is to find the integer part so simple declaration int would do. Strictly, "2.0" is not an integer. Please guide me. Thanks.
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

  3. #3
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by jackson6612 View Post
    Are you alluding to the fact that long has a wide range? But the purpose is to find the integer part so simple declaration int would do. Strictly, "2.0" is not an integer. Please guide me. Thanks.
    You started so well, and then ... you do know what the word "wide" means, right?

    Anyway, as an example, you could use 1.12e17.

  4. #4
    Registered User
    Join Date
    Mar 2011
    Posts
    254
    Quote Originally Posted by tabstop View Post
    You started so well, and then ... you do know what the word "wide" means, right?

    Anyway, as an example, you could use 1.12e17.
    Thanks, tabstop, and sorry for asking this again.

    But don't you think using int& wouldn't hurt that much? Please let me know. Thanks.
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

  5. #5
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Quote Originally Posted by jackson6612 View Post
    Thanks, tabstop, and sorry for asking this again.

    But don't you think using int& wouldn't hurt that much? Please let me know. Thanks.
    Run the following to see the point:
    Code:
    #include <iostream>
    
    int main() {
        float foo = 1.12e17;
        long bar = foo;
        std::cout << foo << " " << bar << " " << std::endl;
        return 0;
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. int&, passing of arguments by reference, etc
    By jackson6612 in forum C++ Programming
    Replies: 6
    Last Post: 05-17-2011, 03:26 AM
  2. Managed C++, passing arguments by reference
    By jimzy in forum C++ Programming
    Replies: 8
    Last Post: 11-02-2007, 01:03 PM
  3. passing bye parts of program
    By ReLiEnThAwK in forum C++ Programming
    Replies: 5
    Last Post: 04-06-2006, 12:02 PM
  4. Finding Seperate Parts of Date
    By drdroid in forum C++ Programming
    Replies: 1
    Last Post: 02-14-2003, 09:24 PM
  5. How to get the fraction part of a float as an integer?
    By A. Motaz in forum C++ Programming
    Replies: 1
    Last Post: 10-02-2001, 09:00 AM