Thread: Positive integers

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    9

    Unhappy Positive integers

    HI,

    I am relativly new to c ++ and was wondering if there was a function that I could use that will always return a positive integer. For example if I did 1- 5 it would return 4 instead of -4.

    Thank you in Advance

    Craig Smith

  2. #2
    Registered User rmullen3's Avatar
    Join Date
    Nov 2001
    Posts
    330
    abs()

    The absolute value function, found in <math.h>

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Link List math
    By t014y in forum C Programming
    Replies: 17
    Last Post: 02-20-2009, 06:55 PM
  2. find the totals of positive and negative integers
    By noaksey in forum C Programming
    Replies: 5
    Last Post: 05-11-2004, 01:59 PM
  3. Help with homework please
    By vleonte in forum C Programming
    Replies: 20
    Last Post: 10-13-2003, 11:16 AM
  4. how to handle integer overflow in C
    By kate1234 in forum C Programming
    Replies: 8
    Last Post: 04-23-2003, 12:20 PM
  5. Replies: 6
    Last Post: 11-04-2002, 05:11 PM