Thread: Technical Functions...!@#$

  1. #1
    Caffienated jinx's Avatar
    Join Date
    Oct 2001
    Posts
    234

    Technical Functions...!@#$

    Is there any header, lets say Math.h for example, that you could use to retreive the absolute value of a number. Technicaly, if I had the string:
    75656
    and I needed to subtract:

    45562
    and get:

    75656
    - 45562
    ---------------
    30114
    and so on. I would also need to compensate for other problems like:
    34475
    -52434
    and return:

    22041
    I am pretty sure that some one could help me, the main goal is to get the positive value from subtraction of two integers. Or maybe I should use a strFormat and use a switch case method. Oh well, I've confused my self enough for one post. If this makes any sense whatsoever, please tell me so!
    Weeel, itss aboot tieme wee goo back too Canada, eeehy boyss.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,708
    #include math.h

    abs();
    Code:
    #include <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  3. #3
    Caffienated jinx's Avatar
    Join Date
    Oct 2001
    Posts
    234
    Hmmmm.... Please elaborate.

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    int abs( int ) from math.h returns the absolute value of the given number.

    int i = abs( -8152 );

    i is 8152
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Caffienated jinx's Avatar
    Join Date
    Oct 2001
    Posts
    234
    However, I need to return a value like such:

    Code:
    GetDlgItemValue(IDC_EDIT1, nInt);
    GetDlgItemValue(IDC_EDIT2, nInt2);
    int i = abs(nInt);
    int a= abs(nInt2);
    After this I would need to subtract the two but come out with the difference between each induvidual digit, assuming the two values are the same length. I think that i am now leaning toward more of a strFormat approach. What do you think?
    Weeel, itss aboot tieme wee goo back too Canada, eeehy boyss.

  6. #6
    of Zen Hall zen's Avatar
    Join Date
    Aug 2001
    Posts
    1,007
    ..or you could do -

    int whatever = abs(nInt - nInt2);
    zen

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Functions and Classes - What did I do wrong?
    By redmage in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2005, 11:50 AM
  2. calling functions within functions
    By edd1986 in forum C Programming
    Replies: 3
    Last Post: 03-29-2005, 03:35 AM
  3. Factory Functions HOWTO
    By GuardianDevil in forum Windows Programming
    Replies: 1
    Last Post: 05-01-2004, 01:41 PM
  4. Shell functions on Win XP
    By geek@02 in forum Windows Programming
    Replies: 6
    Last Post: 04-19-2004, 05:39 AM
  5. functions - please help!!!!
    By linkies in forum C Programming
    Replies: 1
    Last Post: 08-21-2002, 07:53 AM