Formating double number

hi all. I have problems print numbers > 999999 in double format:
public class P {
     public static void main(String arg[]) {
          double d=234345*2532.34;
          System.out.println(d);
}output: 5.934412173000001E8
how can i print amplified format: "593441217.3"?
thanks.

import java.text.DecimalFormat;
public class P {
     public static void main(String arg[]) {
          double d=234345*2532.34;
          DecimalFormat df = new DecimalFormat("#############.##");
          System.out.println(df.format(d));
}output its ok
thanks hunter
can i quit this limits ( now limit is 13 int and 2 decimal positions).?

Similar Messages

  • Noise while formatting double numbers

    Hi all,
    When I try to format a number with 10 to 12 decimal point, I get noise as the number gets bigger. I know this is because computer can not handle all the floating point numbers when converted to binary. I wanted to see if any one know how to find out how many decimal points I can saw for perticular number with out getting noise at the end. For example, if you try to format double number like 99999.99 using snprintf and try to have 12 decimal points them you get 99999.990000000005. Is there any way to avoid this and work around.
    Thanks...

    Look up the DecimalFormatter/NumberFormatter APIs.
    Steve

  • Format a number

    Hi,
    I need some help with formating a number.
    I am having a string object of format '00000' and i want to have it formatted to '000.00'
    Is there a way i can change it to double by specifying the format?
    Let me know if there is any way i can do it using Number format or Decimal format?

    Does this String come in any other flavors? Is it to represent currency? Myself, if this were currency, I'd read it in as an int and even save it and manipulate it as an int. Then when I wanted to display it, I'd divide by 100.00 and use a either a NumberFormat.getCurrencyInstance if it's currency, or else a DecimalFormat if not.

  • May I know how to round a double number to 2 decimal points?

    if I have a double number 135.25689951591, how can I round this number to make it output as 135.26?

    double number = 135.25689951591;
    java.text.DecimalFormat df = new java.text.DecimalFormat("#.00");
    System.out.println(df.format(number));Alll this will do is display the value 135.26, number will still hold 135.25689951591

  • How to format a number to "+0000000000.123,45"

    Hi! my name is Jorge. My problem is that I need to format a number to a extrange format. I know how to change the decimal point, the number of integer and fraction, etc.
    But the problem is I want the number with N zeros at the begining but only with decimal point if there are digit. And I need the sign always appear, if it is a minus or a plus.
    For example:
    123,456.789 -> +0000000000123,456.789
    -1,234,567.890 -> -00000000001,234,567.890
    It is possible using a pattern. There is someone who show me how, because I can't find it the rigth pattern.
    Thank you very much,
    Jorge.

    Here play with this - you'll need to tidy it up a bit for numbers under a 1000 or a million - maybe a parseInt function // * here would do it - Anyway, its a start. I've written it in a drag 'n' drop style so you can test and play first beofre applying it. Thats what I usually do - though I seem to recall java programmers think that 'drag-n-drop' is a dirty term - NO OFFENCE GUYS _ I'M NEW !!!
    import java.text.*;
    public class Decimal_Fmt {
    public static void main (String []args) {
    double d = Double.parseDouble(args[0]);
    DecimalFormat fmt = new DecimalFormat("#0"+","+"000"+","+"000.0#####");
    // * Possibly add a function call here ? *
    String d_str = fmt.format(d);
    System.out.println("DecimalFormat: "+d_str);
    }

  • J2me :: format a number

    Hello.
    First I want you to know that I am very new to J2ME. In fact I have about 3 days since the first time I coded my first line.
    Well, I'm trying to write a midlet with Netbeans Mobility Pack that fetchs for a currency exchange value on Yahoo and displays it. Everything is ok until here.
    Then, the returned type that I get from Yahoo is a double and I want to format it as currency. So I tried importing java.text to use NumerFormat but the compiler throws an error saying package java.text does not exist.
    Isn't java.text included in WTK? Or is there a way that I can format a number like 123456.789 as 123,456.78 without using this package?
    Any ideas will be appreciated.
    Thanks in advance

    Isn't java.text included in WTK? No it's not included.
    Or is there a way
    that I can format a number like 123456.789 as
    123,456.78 without using this package?There is always a way! Just use some string maniplulation and put some comma's between your numbers.

  • Format a number, pad with spaces

    I want a simple way to format a number into a String, but have it padded with spaces. My code started like this:
    DecimalFormat myFormatter = new DecimalFormat("###.00");
    String output = myFormatter.format(12.5);
    The output is '12.50' when I want ' 12.50' (leading space). There's got to be an easy way to do this!
    Thanks for your help

    What you probably wanted to do was print some numbers in a column (of JTextArea's, for example) so that the decimal points line up.
    I wasted some more time and came up with the following:  String formattedNumber = numberPad(number, "###.00E0");
      static String numberPad(double number, String format) {
        int desiredDecimalPosition = format.indexOf('.');
        DecimalFormat numFormat = new DecimalFormat(format);
        String formattedNum = numFormat.format(Math.abs(number));
        formattedNum = formattedNum.replace('E', 'e');
        int exponentPosition = formattedNum.indexOf('e');
        if (exponentPosition < 0)
          exponentPosition = formattedNum.length();
        formattedNum = formattedNum.replaceFirst("e0", "");
        int decimalPosition = formattedNum.indexOf('.');
        formattedNum = (number > 0 ? " " : "-") + formattedNum;;
        if (decimalPosition < 0)
          decimalPosition = exponentPosition;
        int padding = desiredDecimalPosition - decimalPosition;
        if (padding > 0)
          formattedNum = "        ".substring(8 - padding) + formattedNum;
        return formattedNum;
      }Now it turns out that- despite the fact that I've told DecimalFormat to format precisely 2 digits to the right of the decimal, it sometimes randomly gives me 3, and (less often) 1!
    All this trouble just to try save 16kB of Henrik Bengtsson's sprintf in my jar file...

  • Formatting double type output

    Hi all,
    can anyone teach me how to format the output of a double data type in the console?
    let's say i have:
    double myNum = 1.234567890123;if i want only four digits after the decimal point (ex. 1.2345), how am i supposed to do it?
    thanx a lot!

    i mean, how do i convert it from 10 digits to the
    right of the decimal point to become only four?
    when i was learning C, we simply put:
    printf("The number is: %2.4f"+myNum);
    is there any similar way on how doing it? because i
    have a lot of double number to be printed out, and if
    i dont limit the format, my screen was flooded!
    thanx a lot!And the DecimalFormat class does that for you. Look at the following:
    DecimalFormat myFormatter = new DecimalFormat( "###.####" );
    String output = myFormatter.format(value);
    System.out.println("Without formatting, value == " + value + ", with formatting, value ==  " + output);� {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to Format a number to support multiple languages

    I am trying to format a number so that it shows up with the corret decimal separators and thousands separators for different regions/languages, but can't seem to.
    123456.223 is 123,456.223 (US English) and 123 456,223 in French (France)
    I don't know how many such regional settings are being used and what the decimal and thousands separators are.
    If you set the Format to 'System Default Number Format', all is well (But I have to live with 2 digits after the decimal). However, if I want to customize it by saying choosing one of the preset formats or using 'Customize'(say 3 digits after the decimal, for example), then, if I am designing the report in US English setting, the separators from that setting are used, even when the report is generated in French locale. Even if I try to put in a condition for these separators and use 'DefaultAttribute', it doesn't seem to help.
    One workaround is to format the number as a string and display the string instead (this time use ToText() function and provide the no. of decimal places needed). But I have aggregations based on this field and they don't work in with string fields.
    Could someone advise me if there is a way to solve this problem? (I'm hoping that there is some way, perhaps an easy one to overcome this problem.) It seems anytime I want to change the default setting, the current values are stored and used irrespective of the reigonal setting.
    Any help is greatly appreciated.
    Thank you,
    Raghu

    Use the default settings and then it should format according to the local PC settings.

  • How to format large number field in XML so that it appears as is in Excel

    Hi
    I need help in formating the number field so that the number displays completely in Excel.
    Ex: 12345678889453 and this appers in Excel as 1.23457E+13
    Please let me know if you have any idea on this.
    Thanks

    Hi friends,
    Thanks to all of you that you all have replied my question and given your answers.
    Thanks to all of you specially Alpana Phapale, Wallie Chang, Poonam Thorat and Raghavendra Gadhamsetty, the answers given by you is the perfect one may be in different ways and only one can be used by me. But your answers were exactly correct.
    Thanks to Asha Lund, your answers is also correct but the result as per my report should be in figures and not in words.
    Whatever it may be but for repling thanks to you too.
    Please be always with me, I am very new to Crystal Report and just learnt by my own as my Boss ordered me to do this and I have to make about 50 reports within 15 days. I think the day will start from today.
    Well friends thanks a lot again for all your effort.

  • Apex 4.2: Date picker & format mask number

    Hello
    In Apex 4.2, in a Date Item, how can I modify the date picker to set Monday as the start of week day? I can set Monday as the start of week day on a calendar, but not in a Date Item.
    In a Number Item, there's no format mask to set the comma char as a decimal separator and the dot char as a thousand separator. How can I create a new format mask number?
    Thank you.
    Edited by: user7034195 on 12-mar-2013 3:24

    for the Date Item, you can check this link, you have to call the process on the page load
    http://stackoverflow.com/questions/1313317/set-start-day-of-the-week-in-jquery-ui-datepicker
    and for the Number format, there's a little trick involved, will try to explain
    First of all convert you items from Number field to simple Textfield.
    1. Write this in your items Post Calculation Computation: TO_CHAR (:item_name, '999G999G999G999G990D00', 'NLS_NUMERIC_CHARACTERS = '',.''')This will do the number formatting you want, but in oracle above format is not acceptable, so while submitting the above values to database we need to undo the changes for that you can use the below code.
    2. Create a Computation "After Submit" for every item you did the above formatting and copy this code in it: replace(replace('1.00.00,00','.',''),',','.') for the 2nd step you can create a package/function which will get the items value as string and do the conversion as number using above code and return back the number.
    This should help you.
    Regards,
    Tauceef

  • Formatting a number

    hi all,
    help me out .. iam facing problem with formatting a text....
    for ex: i want to format a number 34347.98 to 34'347.98 using NumberFormat class.... but iam not able to get it.
    help me how to format above its very urgent....
    thanks
    Naresh G

    Wouldn't a new DecimalFormat("##'###.##') do the trick?
    kind regards,
    Jos

  • RE: (forte-users) Formatting a number

    Thank you. That worked out great.
    ka
    -----Original Message-----
    From: Thompson Ian [mailto:Ian.Thompsonicl.com]
    Sent: Friday, February 18, 2000 9:35 AM
    To: 'Amin, Kamran'; 'Forte User'
    Subject: RE: (forte-users) Formatting a number
    Ka,
    Try using TextFormat in combination with NumericFormat - like this:
    strfmt : TextFormat = new;
    numfmt : NumericFormat = new;
    number : IntegerData = new;
    numberastext : TextData;
    numfmt.Template='L0000000';
    strfmt.Template='A###-####';
    number.SetValue(source = 23456);
    // Format the number into a TextData.
    numberastext=strfmt.FormatText(source = numfmt.FormatNumeric(source =
    number));
    You may have tried this already, but I hope it helps.
    Regards
    Iain
    -----Original Message-----
    From: Amin, Kamran [mailto:kamran.aminframeworkinc.com]
    Sent: 18 February 2000 13:37
    To: 'Forte User'
    Subject: (forte-users) Formatting a number
    I like to format a number as follows:
    L###-#### - Where a number like 23456 would format to L002-3456.
    Is there any way to do this in Forte using the NumericFormat object.
    thanks in advance.
    ka
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

    Thank you. That worked out great.
    ka
    -----Original Message-----
    From: Thompson Ian [mailto:Ian.Thompsonicl.com]
    Sent: Friday, February 18, 2000 9:35 AM
    To: 'Amin, Kamran'; 'Forte User'
    Subject: RE: (forte-users) Formatting a number
    Ka,
    Try using TextFormat in combination with NumericFormat - like this:
    strfmt : TextFormat = new;
    numfmt : NumericFormat = new;
    number : IntegerData = new;
    numberastext : TextData;
    numfmt.Template='L0000000';
    strfmt.Template='A###-####';
    number.SetValue(source = 23456);
    // Format the number into a TextData.
    numberastext=strfmt.FormatText(source = numfmt.FormatNumeric(source =
    number));
    You may have tried this already, but I hope it helps.
    Regards
    Iain
    -----Original Message-----
    From: Amin, Kamran [mailto:kamran.aminframeworkinc.com]
    Sent: 18 February 2000 13:37
    To: 'Forte User'
    Subject: (forte-users) Formatting a number
    I like to format a number as follows:
    L###-#### - Where a number like 23456 would format to L002-3456.
    Is there any way to do this in Forte using the NumericFormat object.
    thanks in advance.
    ka
    For the archives, go to: http://lists.xpedior.com/forte-users and use
    the login: forte and the password: archive. To unsubscribe, send in a new
    email the word: 'Unsubscribe' to: forte-users-requestlists.xpedior.com

  • How to read the decimal portion of a double number? (using scanner method)

    hello Java pros....
    I need to read the integer and decimal part of a double number, one independently of the other.
    I must be able to assign the integer part to a variable, and the decimal part to a different variable.
    Is there a method that does what I need directly after reading the initial value (double) ?
    or, should I include the condition to read the decimal point somehow?
    the initial value will be input from the console using a scanner method.
    lets say the number I have is 123.345
    I must be able to separate 123 from 345 and use them independently.
    thank you all!!
    al

    The scanner should read in the user input as a string, so you have "123.456". Do something like the following:
    String   doubleNumber             = "123.456";
    String[] numberParts              = doubleNumber.split("\\.");
    int       wholeNumberPortion       = Integer.parseInt(numberParts[0]);
    int       fractionalPortion        = Integer.parseInt(numberParts[1]);
    System.out.println(wholeNumberPortion  + "." +  fractionalPortion);

  • What is this error java.sql.SQLException: Bad format for number ?

    Dear All,
    I am reading few values from database. Then I get this error "MyError:Error : java.sql.SQLException: Bad format for number 'Sarawak' in column 6. " So what is this error referring to. I have checked the database column and its value fits according the data type. Any hints please?

    I have checked the database column and its value fits according the data type.Check again. Then check again. Keep checking until you find your error. You are trying to read a string containing "Sarawak" as a number. You have "getInt(6)" or other numeric type, and the 6th column in the select statement is not numeric.

Maybe you are looking for

  • What are the dependencies of crdb_oracle.dll in V10?

    Post Author: PeterB CA Forum: General I have had a problem running a V10 .rpt file from within an application with embedded V8.5 reports - The error message stated that crdb_oracle.dll could not be found, so I copied it onto the machine in question a

  • Can't get flash player to work!!

    I have downloaded and installed Adobe flash player several times but I can't get it to work. every time I try to watch a video on youtube it says I need the upgraded version of flash player. I have version 11.  I have went online and followed instruc

  • Applications missing in Home folder?

    Hi, I was trying to do a back-up of my home/users folder which should essentially contain everything on my hard drive, when I noticed that in my home folder, the applications folder is empty. How is the best way to put all my my applications back in

  • Cross Docking Process Flow - ECC6.0

    Hi, Can some explain what is the process flow for cross docking in ECC 6.0. How to mark a customer as Cross docking customer? Thi sis the process flow we are trying to map in ECC6.0 for croos docking.Please let me know is this process flow can me map

  • Macbook pro 15'' 4gb ram and 128gb solid state

    example: wen  play  on facebook and open new page it is my problem. thank's for  help