Results 1 to 3 of 3
Thread: bitwise not ~ operator
- 02-10-2010, 06:25 AM #1
Member
- Join Date
- Feb 2010
- Posts
- 3
- Rep Power
- 0
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);
- 02-10-2010, 06:41 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,537
- Rep Power
- 11
i was just wondering what i'm doing wrong below with the ~ operator ...
Assuming that -n and ~n are equal.
- 02-10-2010, 06:49 AM #3
Senior Member
- Join Date
- Mar 2009
- Location
- USA
- Posts
- 127
- Rep Power
- 0
Similar Threads
-
Bitwise operation syntax not recognized?
By Krooger in forum New To JavaReplies: 2Last Post: 12-08-2009, 05:17 AM -
Increment Operator Example
By abimaran in forum New To JavaReplies: 10Last Post: 11-03-2009, 04:45 PM -
Confusing with bitwise NOT operator
By Willi in forum New To JavaReplies: 4Last Post: 10-16-2009, 11:06 PM -
Bitwise operations with long
By NewJavaBean in forum New To JavaReplies: 2Last Post: 04-07-2009, 07:37 PM -
Using the bitwise operators
By Java Tip in forum java.langReplies: 0Last Post: 04-17-2008, 07:39 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks