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 2 of 2

Thread: Error: invalid float literal

  1. #1
    Junior Member
    Join Date
    Apr 2014
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Error: invalid float literal

    Hi people,
    This is my very first post in this site. While doing trial and error got caught in the below scenario.

    public class Crypt {

    public static void main (String args[])

    {
    /*all I want is calculate a binary number (ex -: 22 , 34) using decimal base (10n).

    *So, I have to convert 2 p into 10n form so I have to find n in terms of p . We have x as the input.
    * The formula works as below.
    *2p =10n
    *p ln (2) =n ln (10)

    *n = p [ln(2) / ln(10)]

    *2 p = 10 p [ln(2) / ln(10)]

    */

    double constant=(Math.log(2)/Math.log(10));

    // for the sake of readability removed some piece of repititive execution

    int p=4; // the power of 2

    double data=1e(p*constant); // data is the Pth power of 2

    // compiltion stops by this point. compiler says invalid float literal.

    System.out.println(data);

    }

    }


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,718
    My Mood
    Mellow
    Thanks
    231
    Thanked 706 Times in 692 Posts

    Default Re: Error: invalid float literal

    Welcome to the forum! Please read this topic to learn how to post code in code or highlight tags and other useful info for new members.

    Please post your code correctly as described at the link I've provided above. When you're asking for help with errors, copy the entire error message and stack trace exactly as it appears at your end and paste it into a post, using tags if large.

    This:

    data=1e(p*constant)

    is not a valid Java statement, at least not with what you've shown us. What is 'le' or '1e'?

Similar Threads

  1. Replies: 2
    Last Post: March 23rd, 2014, 08:44 AM
  2. Replies: 0
    Last Post: December 5th, 2013, 06:49 PM
  3. Error: Invalid method declaration; return type required. Related to JFrames.
    By Pakupakuman in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 26th, 2012, 05:47 PM
  4. Error with taking float numbers from an input dialog box.
    By deepcrimson76 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 26th, 2012, 12:58 PM
  5. error: invalid meyhod declaration
    By iswan in forum AWT / Java Swing
    Replies: 0
    Last Post: September 30th, 2011, 08:03 PM

Tags for this Thread