Results 1 to 3 of 3
  1. #1
    kezkez is offline Member
    Join Date
    Feb 2010
    Posts
    3
    Rep Power
    0

    Default bitwise not ~ operator

    hi, i was just wondering what i'm doing wrong below with the ~ operator ...

    public class PiTest
    {
    public static void main (String[] args)
    {
    System.out.println(Pi.piR(2));
    System.out.println(Pi.piI(2));
    System.out.println(Pi.piI(420000));
    }
    }
    class Pi
    {

    private int n;
    public static double piR(int n)
    {
    if (n < 1)
    return 0;

    double v = n;

    if ( v % 2 == 0)
    return piR(n-1) - (4.0 / (2*v-1));
    // ~4 / (2*v-1) + piR(n-1) ;
    else
    return (4 / (2*v-1)) + piR(n-1);

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    i was just wondering what i'm doing wrong below with the ~ operator ...

    Assuming that -n and ~n are equal.

  3. #3
    Aseem is offline Senior Member
    Join Date
    Mar 2009
    Location
    USA
    Posts
    127
    Rep Power
    0

Similar Threads

  1. Bitwise operation syntax not recognized?
    By Krooger in forum New To Java
    Replies: 2
    Last Post: 12-08-2009, 05:17 AM
  2. Increment Operator Example
    By abimaran in forum New To Java
    Replies: 10
    Last Post: 11-03-2009, 04:45 PM
  3. Confusing with bitwise NOT operator
    By Willi in forum New To Java
    Replies: 4
    Last Post: 10-16-2009, 11:06 PM
  4. Bitwise operations with long
    By NewJavaBean in forum New To Java
    Replies: 2
    Last Post: 04-07-2009, 07:37 PM
  5. Using the bitwise operators
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:39 PM

Tags for this Thread

Posting Permissions

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