Technical Functions...!@#$

This is a discussion on Technical Functions...!@#$ within the Windows Programming forums, part of the Platform Specific Boards category; Is there any header, lets say Math.h for example, that you could use to retreive the absolute value of a ...

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

    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,659
    #include math.h

    abs();



    ITSA
    Socket Library!

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

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    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
    235
    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
    zen
    zen is offline
    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, 02: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

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