Results 1 to 3 of 3

Thread: Pos to Neg/Neg to Pos [Resolved]

Threaded View

  1. #1

    Thread Starter
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418

    Pos to Neg/Neg to Pos [Resolved]

    Anyone know of a function in the Java API that returns an integer that can convert neg/pos or pos/neg? I can code it but id rather use a function if one exists.
    Code:
    /*
    small prog to test formulas
    formulas --> -/+ (-n == ~n + 1) or ((-n + 1) ~n == n)
    +/- (n == ~n + 1) or ((n-1) ~n == (-n))
    */ 
      
      class progTest{
        public static void main(String[] args){
    
         if(args.length == 1){
           
             int n = Integer.parseInt(args[0]); 
              // n = ~n + 1; can use either
               n = n - 1;
               n = ~n; 
               System.out.println(n); 
          }else{
             System.out.println();
             System.out.println("Usage 1 arguement");
           }
         }
       }

Posting Permissions

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



Click Here to Expand Forum to Full Width