ME AGAIN......heheheh

This is a discussion on ME AGAIN......heheheh within the C++ Programming forums, part of the General Programming Boards category; Thanks for that info people but I think you miss taken me, Im after a way of checking a float ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    5

    Talking ME AGAIN......heheheh

    Thanks for that info people but I think you miss taken me,
    Im after a way of checking a float if it has a decimal point in it or not

    So I a can pass the input to the next stage!!!

    If int as decimal or else

    p.s still learning how to type tho......lol

  2. #2
    Registered User ski6ski's Avatar
    Join Date
    Aug 2001
    Posts
    133
    Ok that is a different question than what you had posted before.
    To check if a number has a decimal part.......man am I tired...
    I think you will use the '%' symbol. I will get back with you on that.....right now it is bed time, and I can not think.
    C++ Is Powerful
    I use C++
    There fore I am Powerful

  3. #3
    Registered User kitten's Avatar
    Join Date
    Aug 2001
    Posts
    109
    Ok, you can easily test if a floating point variable has desimal numbers.
    Code:
    if (Variable == (int)Variable)  // test if there is no desimals
    if ( !(Variable == (int)Variable) )  // test if there are desimals
    This tests if the floating point value is same as its integer conversion.
    Making error is human, but for messing things thoroughly it takes a computer

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,500
    Read the input as a string, then use (say strchr) to look for a decimal point.

    Do what you need to do, depending on whether you find one or not.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21