Results 1 to 6 of 6
  1. #1
    sara12345 is offline Member
    Join Date
    Dec 2009
    Posts
    59
    Rep Power
    0

    Default taking number value without sign

    Hello
    I'm dealing with positive and negative numbers. I want just to take the number without sign because I will do some comparison so I need to do comparison without considering sign. How can I do it?
    thanks

  2. #2
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    10

    Default

    Java Code:
    System.out.println(Math.abs(-223));
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  3. #3
    j2me64's Avatar
    j2me64 is offline Senior Member
    Join Date
    Sep 2009
    Location
    Zurich, Switzerland
    Posts
    962
    Rep Power
    9

    Default

    Quote Originally Posted by sara12345 View Post
    Hello
    I'm dealing with positive and negative numbers. I want just to take the number without sign because I will do some comparison so I need to do comparison without considering sign. How can I do it?
    thanks

    the class math has a abs() method to convert negative numbers. use it.

  4. #4
    sara12345 is offline Member
    Join Date
    Dec 2009
    Posts
    59
    Rep Power
    0

    Default

    ok thanks but are the numbers must be in integer format or float
    thanks alot

  5. #5
    PhHein's Avatar
    PhHein is offline Senior Member
    Join Date
    Apr 2009
    Location
    Germany
    Posts
    1,429
    Rep Power
    10

    Default

    Did you read the API docs which j2me64 has linked in one minute?! You're fast.
    Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x]
    The Ubiquitous Newbie Tips

  6. #6
    sara12345 is offline Member
    Join Date
    Dec 2009
    Posts
    59
    Rep Power
    0

Similar Threads

  1. Taking a character off the end of a string.
    By AJArmstron@aol.com in forum New To Java
    Replies: 5
    Last Post: 05-05-2010, 03:56 AM
  2. Printing the Number of Times a Number in a Range Shows up
    By space4rent00 in forum New To Java
    Replies: 1
    Last Post: 02-05-2010, 11:42 PM
  3. Taking Java In School Need Help
    By xEuPhOrIcSx in forum New To Java
    Replies: 7
    Last Post: 02-04-2008, 09:02 AM
  4. Taking passwords on the console
    By eva in forum Advanced Java
    Replies: 2
    Last Post: 12-19-2007, 10:28 AM
  5. Taking input from console
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 11-05-2007, 05:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •