Double is giving the garbage value

The following code:
public class Hello
public static void main(String[] args)
double d = 12.12345678235467F;
System.out.println("d = " + d);
When the above code runs, then i am getting the garbage value.
The first 8 decimal digits are correct but after that rest of the digits are garbage value. Why?
This problem occurs only when the double value has more than 8 decimal digits and the value is appended with "F".
any answer?

J2ME_discussion wrote:
Can you explain it in simpler terms.
When the value is not appended with "F" then i am getting the correct value i.e. the value declare is same as the value printed in the console output (16 significant decimal digits)
But, if it gets appended with "F" then the problem starts.Float (32 bits) can handle a smaller range of numbers than double (64 bits). Put F at the end, and it is a float.
Also, neither store numbers as X number of significant decimal places. I don't understand the math behind it all, and for general use you don't need to. You really only need to know that both float and double do not store numbers are X number of significant decimal places, so some numbers (0.1 I believe is one) will only be an approximation of the actual value. If you absolutely require X number of significant decimal places then you don't want to be using either double or float, you either want to roll your own using two ints, or use BigDecimal class.

Similar Messages

  • How to select values frm table giving the condition value at runtime in SQL

    Hi All,
    How to select values from a table by giving the condition value at runtime in SQL
    My SQL statement is select * from employee where empno=<empno>, this empno I want to provide at run time. Also I don't have any bind variables defined. Can anyone please tell how can I achieve this. Also do I have to write a SQL or pl/sql statement.

    Hi Roshni Shankar,
    You can use substitution variable in case of SQL.
    SQL> select * from employees where emplployee_id = &emp_id;
    Enter value for emp_id: 100
    old   1: select * from employees where emplployee_id = &emp_id
    new   1: select * from employees where emplployee_id = 100If you want to put condition on varchar values then eighter provide values in single quotes or use single quote for substitution variable.
    SQL> select * from employees where last_name = &emp_name;
    Enter value for emp_name: 'King'
    old   1: select * from employees where last_name = &emp_name
    new   1: select * from employees where last_name = 'King'
    no rows selected
    SQL> select * from employees where last_name = '&e_name';
    Enter value for e_name: King
    old   1: select * from employees where last_name = '&e_name'
    new   1: select * from employees where last_name = 'King'In case of pl/sql you can pass values to procedure and you can use those values at run time.
    create or replace procedure test (p_emp_id number)
    as
       v_last_name      varchar2(100);
    begin
       select last_name
       into    v_last_name
       from  employees
       where employee_id = p_emp_id;
       dbms_output.put_line(p_emp_id ||'    ->    '||v_last_name);
    end;
    show errors
    SQL>exec test(100);
    SQL>exec test(101);Edited by: Gaurav Bhide on Oct 29, 2012 4:07 AM

  • How to display the rows number of times by giving the column values?

    Hi All,
    I want to display the rows number of times as the value exists in num column in the below query
    with t AS
       ( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
         UNION ALL
         SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
         UNION ALL
         SELECT 'krishna' NAME,     'hyd' LOC, 1 NUM FROM DUAL )
      SELECT T.* FROM T
      CONNECT BY ROWNUM <= NUM
    Expected output:
             venkatesh            hyd      2
             venkatesh            hyd        2
             prasad                 hyd        3
             prasad                   hyd      3
             prasad                   hyd      3
             krishna           hyd       1Edited by: Nag Aswadhati on Nov 1, 2012 12:34 AM

    Nag Aswadhati wrote:
    Hi All,
    I want to display the rows number of times as the value exists in num column in the below query
    Expected output:
    venkatesh            hyd      2
    venkatesh            hyd        2
    prasad                 hyd        3
    prasad                   hyd      3
    prasad                   hyd      3
    krishna           hyd       1Using Connect By:-
    with t AS
       ( SELECT 'venkatesh' NAME, 'hyd' LOC, 2 NUM FROM DUAL
         UNION ALL
         SELECT 'prasad' NAME, 'hyd' LOC, 3 NUM FROM DUAL
         UNION ALL
         select 'krishna' name,     'hyd' loc, 1 num from dual )
      select t.name, t.loc
      from t
      connect by level <= num
             and name = prior name
             and (prior sys_guid() is not null);
    NAME      LOC
    krishna   hyd
    prasad    hyd
    prasad    hyd
    prasad    hyd
    venkatesh hyd
    venkatesh hyd
    6 rows selected

  • Not Printing the Content of Object:SOme Garbage Value on Screen

    i have made one program of Vehicle class which adds and prints the Details of Vehicles in the ArrayList but it always showa the Garbage Value in return.
    import java.util.*;
    import java.awt.*;
    import java.lang.*;
    import java.io.*;
    public class Vehicle
         private int reg_no;
         private String model_name;
         private int model_no;
         private int yr_manufacture;
         private String veh_type;
         private int price;
         private int weight;
         private String veh_status;
         public ArrayList vehicles;
         static BufferedReader keyboard = new BufferedReader (new InputStreamReader (System.in));
         public Vehicle()
              //super();          
              vehicles=new ArrayList(10);
         public Vehicle(int regno,String mo_name,int mo_no,int year_manu,String type_veh,int cost,int weight,String status)
         this.reg_no=regno;
         this.model_name=mo_name;
         this.model_no=mo_no;
         this.yr_manufacture=year_manu;      
         this.veh_type=type_veh;
         this.price=cost;
         this.weight=weight;
         this.veh_status=status;
         public void addVehicle() throws IOException
              int regno;
              String mo_name;
              int mo_no;
              int year_manu;
              String type_veh;
              int weight=0;
              int no_person;
              int cargo;
              int cost;
              String status;
              String confirm;
              int countvehicle=0;
              //start of do-while loop
              do {
                   System.out.print("Input the Vehicle Registration Number(Integer):");
                   regno=Integer.parseInt(keyboard.readLine().trim());
                   System.out.print("Input the Vehicle Make(String)eg. Mercedes,Ferrari,BMW etc: ");
                   mo_name=keyboard.readLine();
                   System.out.print("Input the Vehicle Model(Integer): ");
                   mo_no=Integer.parseInt(keyboard.readLine().trim());
                   System.out.print("Input the Vehicle Manufactured Year(Integer): ");
                   year_manu=Integer.parseInt(keyboard.readLine().trim());
                   System.out.print("Input the Vehicle Type:(CAR/BUS/TRUCK)");
                   type_veh=keyboard.readLine();
                   System.out.print("Where do u want this Vehicle to be Loaded:(Type F or I)?");
                   status =keyboard.readLine();
                        if(countvehicle>6 && status.equals("I"))
                        System.out.println("Sorry.........Ferry is Overloaded your Vehicle will be Loacally on the Island");
                        status="Island";
                        System.out.println("Vehicle in Island");
                        else
                             System.out.println("Vehicle loaded on to Ferry");
                             status="Ferry";
                   //decide the weight Factor for the Vehicle
                   if(type_veh.equals("CAR"))
                        weight=1500;                
                   else if(type_veh.equals("BUS"))      
                        System.out.print("Input the boarding No of Person in Bus: ");
                        no_person=Integer.parseInt(keyboard.readLine().trim());
                        weight=(10000+(no_person*75));// Assuming the weight of one Person is 75kg.
                   else if(type_veh.equals("TRUCK"))
                        System.out.print("Input the Truck Cargo Load: ");
                        cargo=Integer.parseInt(keyboard.readLine().trim());
                        weight=(4500+cargo);                
                   System.out.print("Input the Vehicle Price: ");
                   cost=Integer.parseInt(keyboard.readLine().trim());
                   Vehicle regVehicle= new Vehicle (regno,mo_name,mo_no,year_manu,type_veh,cost,weight,status);
                   vehicles.add(regVehicle);//Add to the Vector
                   regVehicle.printall();
                   //Saving the Added Object in File
                   /*try
                             FileOutputStream f_out = new FileOutputStream("Added.txt");                    
                             ObjectOutputStream obj_out = new ObjectOutputStream(f_out);
                             obj_out.writeObject(vehicles.add(regVehicle));
                        catch (FileNotFoundException e)
                             System.err.println("Error:"+ e.getMessage());
                        catch (IOException e)
                             System.err.println("Error:"+ e.getMessage());
                   countvehicle++;
                   System.out.print ("Add a new vehicle (y or n)? ");
                   System.out.flush();      
         confirm= keyboard.readLine();
                   } while (confirm.equals("y")); //end of do while loop
         public Vehicle getVehicle(int index) throws IOException
              return (Vehicle)vehicles.get(index);
         public int getRegNo() throws IOException
              return reg_no;               
         public Vehicle lookUpVehicle (int accnos)throws IOException
    //start of for loop
              for(int i=0;i<vehicles.size();i++)
              //checks if the information entered are correct using an if statement
              if((((Vehicle)vehicles.get(i)).getRegNo()) == accnos)
                   return ((Vehicle)vehicles.get(i));
    return null;
         public void printDetails()throws IOException
              System.out.println("--------Vehicle Details------------ ");
         for(int i=0;i<vehicles.size();i++)
              System.out.println(" " + getVehicle(i));           
         //System.out.println("\n\n");
         //return ((Vehicle)elements());*/
         /*Iterator it = vehicles.iterator();
              while (it.hasNext())
                   System.out.println(it.next());
         public void printall()
              System.out.println(reg_no);
              System.out.println(model_name);
              System.out.println(model_no);
              System.out.println(weight);
    }

    sohamdave wrote:
    what toString will contain in them.i didn't get you there.it is the whole data type-casted to String or only object type-casted to StringSimply return a String representation of the Vehicle object; frequently the String contains the member variable values, e.g.
    public String toString() {
       return model_name+" "+veh_type;
    }The List toString() method itself invokes your method when the List itself needs to be printed.
    kind regards,
    Jos

  • Not able to get the full value from request.getParameter()

    hi all,
    Iam giving a text input value as" Analysis and tracking" in one jsp form.
    while fetching and assigning the value to another variable using request.getparameter , iam getting only the text "Analysis" , the space after it were ignored andnt displaying it.
    Help me in solving this.
    thanx
    Balaji

    I think you are code is something like this
    <input name="xyz" type="text" value=<%=variable%>>
    HTML ignores spaces. Therefore you are only getting Analysis, the first word, when your browser encounters the first space it ignores whatever is present after that.
    One way of overcoming this is putting double quotes around the text value
    <input name="xyz" type="text" value=<% out.println("\"" + variable + "\""); %>
    Thanks.

  • How to set the Default value in the picklist and LOV

    Hi All,
    I have created a table with some of the columns as picklist and some of the columns as Lovs to insert some data into the tables as per the client requirement.
    I want to make one value as default for the picklist and one value as default for the Lov.
    Could you please let me know how can we show one value as default in the pick list or Lov.
    thanks in advance.
    jay

    can u please help how can we set the initial value dynamically with the userid
    For that i was passing the value from process Request of the lovCO by using the get user id to the vo query in the vo
    but its not giving the initial value as default dynamically depending on the user id
    could you please let me know the solution.
    Thanks
    Ajay

  • How to get  --Last date of the Last value .

    Dear All,
    I have a report like
    Material – Country – Current Price
    1112-----  Singapore  -
      100
    1112-----  Japan  -
      120
    1112-----  Malesia   -
      99
    Here current price is Last Value of the particular Material on particular Date.
    This I can get based on Key figure Aggregation ( Last Value and reference Character 0CALDAY ), It is giving the last Value of the Particular Material.
    Now my user wants to see Last date of the value ( Date of the Value )
    Example :-
    Material – Country –  Date --Current Price
    1112-----  Singapore  -
    01/04/2008 -- 100
    1112-----  Japan  -
    04/05/2008 -- 120
    1112-----  Malesia   -
    05/05/2008 -- 99
    If  I drill down the date in my  report  it is showing all dates , my user wants to see only last date .
    Hope some one has solved this issue , please help me to solve this issue.
    Regards,
    SHAIK.

    I have created a keyfigure with date as a data type.
    In aggregation tab, I selected  aggregation Maximum.
    Upto DSO, data is Loaded perfect. Ok.
    I added the same key figure in cube , When I am trying to Activate the Transformation,
    It is giving Error message.
    Rule 17 is invalid and is being deleted. The reason for this is that a field or InfoObject that is used in rule 17 has been deleted in the source or target of the transformation ODSO ZPL_DSO1 -> CUBE ZPLATT_C (0GH6MHANQ2J79LXZBLGIJ9ZK9LWHK6RS)
    Plz Advice.
    Regards,
    SHAIK
    Edited by: shaik on May 7, 2008 5:46 PM

  • Get the modified value from MessageTextInput

    Hi OAF Guys,
    I am displaying a value in MessageTextInput using dynamic VO. I am trying to modify this value thruough UI, but when i get the value in the code, it is giving the old value. How can i get the modified one?
    Thanks & Regards
    Thanks&Regards
    U.Palakondaiah.

    You are welcome.
    When you post the OAF page, this is what happens:
    1)Calls processFormData, this posts the form fields to the VO and in turn to the EO
    2)then Calls, processFormRequest
    So, you need to call pageContext.getParameter in your processFormRequest to get the value for messageTextInput.
    Try this and let me know if you still run into issues.
    Hope this helps
    Srini

  • Error giving a default value to a date column in the attribute settings.

    When im giving a default value to a date column in the attribute settings i get this error when im running my jsp page (bc4j web application):
    Error Message: JBO-25009: Cannot create an object of type:oracle.jbo.domain.Date with value: 31-dic-2099
    How can i fix that?
    Thank u

    The default date format for oracle.sql.DATE which oracle.jbo.domain.Date extends is "YYYY-MM-DD"

  • At a time of uploading the file its giving a junk value.

    Hi  All,
    I am uploading .DOC file using GUI_UPLOAD function and its giving junk value in the internal table at a time of uploading the file.
    Is there any alternative or any function which can help me to upload the .DOC file or any scanned file?
    And is there any possibility to convert the junk value to the string or character?
    I would like to mention the version as i'm working on 5.0.
    Regards,
    Bhavani

    use File_type as 'BIN'

  • Profit center report showing double the plan value comparing to cost center

    Dear Friends,
    We have an issue with the profit center report wherein we have maintained forecast value in version 2 in cost centers and when we run profit center report the values are showing double the value which we maintained in cost centers. Is this the problem in running 1KE0 transaction.?. We have run 1KE0 to update the missing value by deleting the existing values, so few profit center report is corrected but many other profit center report has gone wrong.
    Could you please guide me to correct the values. Business requires to see the same value in cost and profit center. Note; We have created cost and profit centers the same code and assigned to each other.
    Thanks,
    Lokesh

    No answers yet

  • Sequence.nextval doubles the returned value with Execute Statement (F9)

    There appears to be a quirk with sequences in Raptor.
    Has anyone noticed that depending on how you execute this sql (SELECT MYSEQ.NEXTVAL FROM DUAL;) the value returned is either the correct nextval or double what you expected?
    For example, MYSEQ is a simple sequence which increments by 1. If you Execute Statement (F9) then the value returned jumps by 2 instead of 1. If you Run Script (F5) then the value returns jumps by 1, as expected.
    If MYSEQ is changed to increment by 2. The when you Execute Statement (F9) then the value returned jumps by 4 instead of 2. If you Run Script (F5) then the value returns jumps by 2, as expected. No matter what you put for the increment by Execute Statement (F9) always doubles it.
    It always seems to be double. Executing the same scenario in TOAD always returns the correct value (i.e. properly increments).
    Is the query being executed multiple times with Execute Statement? Why is this happening?

    While there is no guarantee from Oracle that sequences produce sequential numbers, this is obviously a case where SQL Developer is running the select statement twice.
    The issue is that queries can actually change information, rather than just retrieve data from the database.
    The following package is a test case:
    create or replace package test_query is
    function get_next_count return number;
    end;
    create or replace package body test_query is
    cnt number := 0;
    function get_next_count return number is
    begin
    cnt := cnt + 1;
    return cnt;
    end;
    end;
    select test_query.get_next_count from dual;
    This query, which should return 1, 2, 3, 4, etc actually returns 2, 4, 6, 8, etc, because SQL Developer is running the select twice.

  • Converting a string to the corresponding value of type double

    Hey, im a really noob at this, but I need some help with this question. I've got to complete this in order to progress to my second year although im not doing programming and will not need it in the second year. The question is as follows:
    "Write a method called convertDouble as follows:
    public double convertDouble (String value) {
    This method should convert its parameter (a string like "3.1415") to the corresponding value of type double. If the string supplied is not a valid number, it should return 0.0 as its result. Note that you can use the method Double.parseDouble() to do the hard work for you. "
    To be honest I dont really have a clue what how to write this so any help would be much appreciated. Cheers guys

    Well the simplest way is to use Java's already inbuilt converter:
    which is if you have a string S which represents a double i.e 3.142
    You can use
    double number = Double.parseDouble(S); and thats it.
    The other way to do it is to loop through the string and check whether it is a number
    by using Character.IsDigit(ch) ? or somethign similar.
    and if it is a digit then subtract a fixed amount depending on its ASCII value.
    so if character with a value of 40 represents 0 (im not sure if it does) then
    any Digit character - 40 would give you the decimal value.
    Please ask questions if i dont make sense.
    Edited by: z0rgy on Aug 18, 2008 7:36 AM

  • Conolidation rules logic doubling and tripling the values

    Hi Experts,
    I am facing the issue when i run the consolidation rule it is doubling or tripling the values. i am using the standard script logic to run. Please find my logic below.
    //Run Consolidation Business Rule
    *RUN_PROGRAM CONSOLIDATION
    CATEGORY = %CATEGORY_SET%
    GROUP = %CONSOSCOPE_SET%
    TID_RA = %TIME_SET%
    *ENDRUN_PROGRAM
    i have not written any business rule more than once under automatic adjustment rule also. Please share your expertise to resolve the issue.
    Thanks,
    Raj

    Hello Raj
    Please check your " Audittrail/ DataSrc" dimension values(Member ID's), especially Your Data Uploads All Manual Audittrail ID's - Data Source Type(Property value) Should be "I"( I like Indiana) for MANUALS.
    I strongly believe that Auditr Trail  ID's  were entered as 1(One) in  Data Source Type. Thats why your Amounts were Double/Triple.
    Hope this will help you
    Thanks
    Venkat

  • Double click on the text to call the other values

    Hi Alll,
    The list of entries are displaying on Adobe form, User want to select one of the key value name displayed on Adobe form.
    When he clicks he need to get the details of that value in a window. Just like the Interactive report.
    Ex as below : table
    S.No   Deatils
    1        Keyvalued 1
    2        Keyvalued 2
    When user clicks on Keyvalued 1 it should get the details of the  Keyvalued 1 in other window.
    please let me know how can I do that
    Thankyou
    Venkata

    Hi Otto,
    I am not good with adobe form. this is the first object to work on
    When the list of keyfields are displaying, I'm not getting any action on the text. i.e click on the text.
    What are the setting for selection of text on Adobe form?  and under which event( I think CLICL) I have to wirte the code to display data.
    can u pls help me out in two or three steps what seeting and where to wrinte
    Regards,
    Prasad

Maybe you are looking for

  • How can I remove a device from my iCloud/Apple ID?

    Hi, I merged my dad's iphone to my Apple ID a while back because he wants to buy an app and I have some credit left over so I let him used my ID on his device. Apparently, all my contacts, pictures from photo stream, and ical are now also in his devi

  • How do I delete a MobileMe gallery?

    How do I delete a MobileMe gallery? I open iPhoto where I created the album, right-clicked on the album to delete. Then I proceeded to watch an indicator dot with and arrow spin, and spin and spin. Finally the spinning stopped, but the album is still

  • I updated Web Mail and now I can't find it, how do I locate it?

    When I opened Firefox I had an update screen which included WebMail Notifier, when I updated and restarted Firefox I am unable to locate WevMail plugin now.

  • System is asking for password while executing t.code RSUDO

    Hi While executing t.code RSUDO ( Execute as user with restricted authorizations) on behalf of other user, system is asking for password. Can you tell the reason for it? System is BW 731. Thanks Saurabh

  • Where to find the ID Type?

    Hi, I am using AII 5.0 and trying to do RFID-Enabled Slap and Ship Outbound Processing scenario. Could you pleas tell me, where I can find the below link. Auto-ID Infrastructure  ->  Basic Settings  -> ID Settings -> Define ID Types Do we need to do