Thread: Why illegal use of floating point?

  1. #1
    Registered User
    Join Date
    Jan 2008
    Posts
    225

    Why illegal use of floating point?

    Hello,
    why there is illegal use of floating point?and what can be done to resolve it?

    Code:
    #include <iostream.h>
    int main(void)
    {
    long double n=234234243234234,i=1221212121,k;
    k=n%i
    cout<<k ;
    return 0;
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    why there is illegal use of floating point?
    operator&#37; is not defined for floating point types.

    what can be done to resolve it?
    Use fmod() from <cmath>

    Incidentally, <iostream.h> should be <iostream>, and I am guessing that 234234243234234 is too large to be an int literal, but should be made a double literal instead.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Jan 2008
    Posts
    225
    Ok thanks laser..!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. checking for floating point number
    By ssharish2005 in forum C Programming
    Replies: 6
    Last Post: 10-18-2005, 08:14 PM
  2. floating point question
    By Eric Cheong in forum C Programming
    Replies: 8
    Last Post: 09-10-2004, 10:48 PM
  3. strtol with floating point
    By Laserve in forum C Programming
    Replies: 3
    Last Post: 07-26-2004, 06:02 AM
  4. floating point variables in edittext controls
    By dootickle in forum Windows Programming
    Replies: 3
    Last Post: 04-15-2004, 11:15 AM
  5. Floating point operations
    By kjc197 in forum C Programming
    Replies: 5
    Last Post: 02-08-2003, 06:44 AM