Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 1 of 1

Thread: Working with log math function

  1. #1
    Member
    Join Date
    Feb 2011
    Posts
    30
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Working with log math function

    I want to output to calculate the following:

    0 - (3/6)logbase2(3/6) = 1/2

    I have this in my program:
    double ratio = 3/6;
    x  = x - (ratio * (logbase2(ratio)));

    which should equal .5 but I keep getting 0.326634259978281

    what am I doing wrong?

    Edit: I figure it out. I should be using:
    (ratio * Math.log(ratio)/Math.log(2))
    Last edited by colerelm; October 15th, 2012 at 06:36 PM.


Similar Threads

  1. Math operations not working..
    By tyeeeee1 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: October 13th, 2012, 12:41 PM
  2. Math.E - what exactly is it?
    By RedCloudTsunami in forum Java Theory & Questions
    Replies: 2
    Last Post: July 10th, 2012, 12:24 AM
  3. [SOLVED] Help with Math.tan and Math.atan
    By Dr.Code in forum Algorithms & Recursion
    Replies: 6
    Last Post: July 2nd, 2012, 05:54 AM
  4. Confusion with Math.toDegrees() and Math.toRadians(). Please help.
    By marksquall in forum Java Theory & Questions
    Replies: 3
    Last Post: June 23rd, 2011, 01:28 AM
  5. Replies: 4
    Last Post: January 27th, 2009, 12:03 AM