Probem with numbers in scientific notation

Hi, I Have a problem and I don�t know how to be solved this.
I have a array of array ( String a[ ][ ] ) with numbers, but this numbers are like 2.48e+08
I need to copy the values of the String a [ ] [ ] into other Double b [ ] [ ] . So I do:
String a [ ][ ] = new String [10][2];
// now I have filled up "a"
Double [ ][ ] b = new Double[10][2];
    for(int i =0;i<10;i++)
        for(int j=0;j<2;j++)
            b[i][j] = new Double( a[i][j]);
.......But my problem is that:
tha values like 2.48e+08 have been transformed to 2.48E8 and I need that they are like the original ones (like 2.48e+08).
it is possible to maintain the original format in this numbers?
Thanks very much

No. A double value does not have a format, it is just a number. However if you want to display those double values in some particular format, then DecimalFormat is the class you use to do that.

Similar Messages

  • Problem: program outputs numbers in scientific notation

    my problem is that my program outputs the population in scientific notation instead of round the number to the nearest one. ex: it should say 30787949.57 instead of 3.078794957 E7
    // Calculates the poulation of Mexico City from 1995 to 2018.
    // displays the year and population
    class PopulationCalculator {
    static double r2(double x) {
         //this method rounds a double value to two decimal places.
    double z=((double)(Math.round(x*100)))/100;
    return z;
    } //end method r2
    public static void main(String args[]) {
         double population=15600000.0;
         double rate=0.03;
         System.out.println("Mexico City Population, rate="+r2(rate));
         System.out.println("Year    Population");
         for (int year=1995; year<=2018;year++)  {
             System.out.println(year+ "    "+r2(population));
        population+=rate*population;
        }//end for loop
        System.out.println("The population of Mexico City reaches 30 million on 02/13/17 at 5:38:34am");
        }//end main
        }//end PopulationCalculator
    {code/]

A: problem: program outputs numbers in scientific notation

Or upgrade to JDK 5.0 and user the new java.util.Formatter capability.
You control the rounding and get localization of the fomatted string at
no extra charge. A quick example:
class A {
    public static void main(String[] args) {
        double d = 30787949.57d;
        System.out.println(java.lang.String.format("%,17.2f", d));
}Example output for three different locales:
$ javac -g A.java
$ LC_ALL=fr_FR   java A
    30 787 949,57
$ LC_ALL=en_NZ   java A
    30,787,949.57
$ LC_ALL=it_IT     java A
    30.787.949,57For more information, refer to:
http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#formatter

Or upgrade to JDK 5.0 and user the new java.util.Formatter capability.
You control the rounding and get localization of the fomatted string at
no extra charge. A quick example:
class A {
    public static void main(String[] args) {
        double d = 30787949.57d;
        System.out.println(java.lang.String.format("%,17.2f", d));
}Example output for three different locales:
$ javac -g A.java
$ LC_ALL=fr_FR   java A
    30 787 949,57
$ LC_ALL=en_NZ   java A
    30,787,949.57
$ LC_ALL=it_IT     java A
    30.787.949,57For more information, refer to:
http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#formatter

  • Select Query resulting in Scientific Notation

    Hello all,
    I am running a Select query through a batch file that extracts data from an Oracle database. Several of the fields that I am extracting from contain numbers that are up to 38 digits long. When I extract the data, it converts the numbers into scientific notation and it is important for me to have the entire field. Is there something I can change to my query that will pull the data in its entire form? This is what I'm running now:
    select * FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy'
    I apologize in advance if this has been answered already.
    Thanks!

    >
    When the extractor finishes, it returns the data into a flat file.
    don't quite understand the TO_CHAR function. Does this function mean I need to say something like this: select "TO_CHAR('column name', 99999999999999999999999999999999999999" FROM ML.APPT where APPTDATE >= to_date('01/1/2010','mm/dd/yyyy')
    >
    Yes- if the tool you use to extract the data (your 'extractor') is converting the numeric data to a string then it is responsible for creating the string in the proper format. If the number is an integer that can have as many digits as you have '9's in your sample format string then that is what you need to do.
    Here is how sql*plus (Oracle's tool) will display the data using default settings
    SQL> select 12345678901234567890123456789012345678 no_format,
      2  to_char(12345678901234567890123456789012345678, '99999999999999999999999999
    999999999999') with_format
      3   from dual;
    NO_FORMAT WITH_FORMAT
    1.2346E+37  12345678901234567890123456789012345678
    SQL>
    ----- TOAD will display something similiar but the default uses more decimal digits in the scientific notation data
    NO_FORMAT,WITH_FORMAT
    1.23456789012346E37, 12345678901234567890123456789012345678You can either format the numeric data in the query using TO_CHAR or the 'extractor' can do it when it converts the data to a string.

  • Long number in CSV file appearing in scientific notation by default

    Hi,
    How can I stop a long number in a CSV file that is opened in excel from appearing in scientific notation by default?
    eg.
    "hello","778002405501 ", "yes"
    becomes:
    hello | 7.78002E+11 | yes
    I have tried wrapping the data in quotes in the csv but to no avail.
    Thanks in advance,
    Alistair

    You can change the extension from ".csv" to ".xls" and use table to form the data and use
    style=”mso-number-format:\@;”
    Please read the sample code below in Classic ASP:
    You can also read in my blog http://sarbashish.wordpress.com/2012/11/30/export-to-excel-how-to-prevent-long-numbers-from-scientific-notation/
    <%
    Response.Clear
    Response.CacheControl = “no-cache”
    Response.AddHeader “Pragma”, “no-cache”
    Response.Expires = -1
    Response.ContentType = “application/vnd.ms-excel”
    Dim FileName
    FileName = “TestDB Lookup-” & month(now)&”-”&day(now)&”-”&year(now)&”.xls”
    Response.AddHeader “Content-Disposition”, “inline;filename=” & FileName
    %>
    <html xmlns:o=”urn:schemas-microsoft-com:office:office” xmlns:x=”urn:schemas-microsoft-com:office:excel” xmlns=”http://www.w3.org/TR/REC-html40″;>
    <head>
    <meta http-equiv=Content-Type content=”text/html; charset=UTF-8″>
    <!–[if gte mso 9]>
    <xml>
    <x:ExcelWorkbook>
    <x:ExcelWorksheet>
    <x:WorksheetOptions>
    <x:DisplayGridlines/>
    </x:WorksheetOptions>
    </x:ExcelWorksheet>
    </x:ExcelWorksheets>
    </x:ExcelWorkbook>
    </xml>
    <![endif]–>
    </head>
    <body>
    <table border=”0″>
    <tr>
    <td>ID</td>
    <td>Name</td>
    </tr>
    <tr>
    <td style=”mso-number-format:\@;”>01234567890123456567678788989909000030</td>
    <td>Sarbashish B</td>
    </tr>
    </table>
    </body>
    </html>
    Sarbashish Bhattacharjee http://sarbashish.wordpress.com

  • Decimal Format and Scientific Notation

    I am trying to print numbers in scientific notation using the Decimal Format class. What follows is a simple test program I wrote to find the bug. So far, I have not found a solution.
    import java.text.*;
    public class formatted {
    public static void main (String Arguments[]) {
    DecimalFormat form = new DecimalFormat("0.###E0");
         double numb = 123456.789;
         System.out.println("Nuber is: " +
    form.format(numb));
    The output of this program is... Nuber is: 123456E
    The output is the same if numb is an int, float, or double. If I format the number as "#####.0" or "#####.00" the output is correct. I think that I am following the rules for formatting a number in scientific notation as the process is outlined in the documentation (provided below).
    ***** From Decimal Format under Scientific Notation ***
    Numbers in scientific notation are expressed as the product of a mantissa and a power of ten, for
    example, 1234 can be expressed as 1.234 x 10^3. The mantissa is often in the range 1.0 <= x < 10.0,
    but it need not be. DecimalFormat can be instructed to format and parse scientific notation only via a
    pattern; there is currently no factory method that creates a scientific notation format. In a pattern,
    the exponent character immediately followed by one or more digit characters indicates scientific
    notation. Example: "0.###E0" formats the number 1234 as "1.234E3".
    Anyone understand how the short program is incorrectly written?
    Marc

    The problem is
    format = "0.###E0"
    input number = 123456.789
    output = 123456E (not scientific notation!)
    This is not scientific notation at all. There is no decimal point given and no value in the exponent.
    I understand entirely that by adding more #'es will provide more precision. The bug I have is the output is not printed in the scientific format; other formats work.
    MArc

  • How can I get Numbers 3.2 to recognise 1e-5 as scientific notation?

    I just changed from Numbers '09 (2.3) to Number 3.2 on Mavericks (OS X 10.9.3) and the new version doesn't seem to recognise "e" or "E" as scientific notation. When I set the cell format to scientific and type "0.0015", Numbers returns "1.5×10^-03". I would however prefer to obtain "1.5e-3". And vice versa: if, after setting the cell format to scientific, I type "1.5e-3", it automatically formats the cell as text and I can't get it to recognise it as scientific notation. With "E" instead of "e", the problem is exactly the same. Does anyone know how I can change this setting? I already tried to search for an answer to my question, but couldn't find anything...

    if, after setting the cell format to scientific, I type "1.5e-3", it automatically formats the cell as text and I can't get it to recognise it as scientific notation.
    I can't duplicate the problem here, either when the cells are formatted as Automatic or as Scientific:
    When you type 1.5e-3 are you making sure not to enter a space after the e?  (When I type a space the cell automatically formats as Text.)
    SG

  • Prevent large numbers from becoming scientific notation on CSV import

    Hi, I'm importing contacts in a .CSV file into iWork Numbers and it takes a 12-digit phone number from a guy in the UK and turns it into scientific notation. So something like 447729803988 becomes 4.4772E+11 which obviously loses some important digits. Is there a way to force Numbers to treat all fields as text on import so it doesn't drop this critical data? thanks
    Sean

    scrollin,
    Your digits are all there. Just format those cells to either Text or Number. Leading zeros do tend to get lost unless you pre-format to text. You can force the cell format to text on the fly by prefixing your input with a single-quote.
    Regards,
    Jerry

  • External table.How to load numbers (decimal and scientific notation format)

    Hi all, I need to load inside an external table records that contain 7 fields. The last field is called AMOUNT and it's represented in some records with the decimal format, in others records with the scientific notation format as, for example, below:
    CY001_STATU;2009;Jan;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Jan;11200100;'60800;CYZ900;41380,77
    The External table's script is the following:
    CREATE TABLE HYP_DATA
    COUNTRY VARCHAR2(50 BYTE),
    YEAR VARCHAR2(20 BYTE),
    PERIOD VARCHAR2(20 BYTE),
    ACCOUNT VARCHAR2(50 BYTE),
    DEPT VARCHAR2(20 BYTE),
    ACTIVITY_LOC VARCHAR2(20 BYTE),
    AMOUNT VARCHAR2(50 BYTE)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY HYP_DATA_DIR
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY NEWLINE
    BADFILE 'HYP_BAD_DIR':'HYP_LOAD.bad'
    DISCARDFILE 'HYP_DISCARD_DIR':'HYP_LOAD.dsc'
    LOGFILE 'HYP_LOG_DIR':'HYP_LOAD.log'
    SKIP 0
    FIELDS TERMINATED BY ";"
    MISSING FIELD VALUES ARE NULL
    REJECT ROWS WITH ALL NULL FIELDS
    "COUNTRY" Char,
    "YEAR" Char,
    "PERIOD" Char,
    "ACCOUNT" Char,
    "DEPT" Char,
    "ACTIVITY_LOC" Char,
    "AMOUNT" Char
    LOCATION (HYP_DATA_DIR:'Total.txt')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;
    If, for the field AMOUNT I use the datatype VARCHAR (as above), the table is loaded but I have some records rejected, and all these records contain the last field AMOUNT with the scientific notation as:
    CY001_STATU;2009;Jan;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Feb;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Mar;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    CY001_STATU;2009;Dec;11220020GR;'03900;CYZ900;-9,99999999839929e-03
    All the others records with a decimal AMOUNT are loaded correctly.
    So, my problem is that I NEED to load all the records (with the decimal and the scientific notation format) together (without records rejected), but I don't know which datatype I have to use for the AMOUNT field....
    Anybody has any idea ???
    Any help would be appreciated
    Thanks in advance
    Alex

    @OP,
    What version of Oracle are you using?
    Just cut'n'paste of you script and example woked FINE for me.
    however my quation is... An external table will LOAD all data or none at all. How are you validating/concluding that...
    I have some records rejected, and all these records contain the last field AMOUNT with the scientific notation
    select * from v$version where rownum <2;
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    select * from mydata;
    CY001_STATU     2009     Jan     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Feb     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11200100     '60800     CYZ900     41380,77
    CY001_STATU     2009     Mar     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Dec     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11220020GR     '03900     CYZ900     -9,99999999839929e-03
    CY001_STATU     2009     Jan     11200100     '60800     CYZ900     41380,77MYDATA table script is...
    drop table mydata;
    CREATE TABLE mydata
    COUNTRY VARCHAR2(50 BYTE),
    YEAR VARCHAR2(20 BYTE),
    PERIOD VARCHAR2(20 BYTE),
    ACCOUNT VARCHAR2(50 BYTE),
    DEPT VARCHAR2(20 BYTE),
    ACTIVITY_LOC VARCHAR2(20 BYTE),
    AMOUNT VARCHAR2(50 BYTE)
    ORGANIZATION EXTERNAL
    ( TYPE ORACLE_LOADER
    DEFAULT DIRECTORY IN_DIR
    ACCESS PARAMETERS
    ( RECORDS DELIMITED BY NEWLINE
    BADFILE 'IN_DIR':'HYP_LOAD.bad'
    DISCARDFILE 'IN_DIR':'HYP_LOAD.dsc'
    LOGFILE 'IN_DIR':'HYP_LOAD.log'
    SKIP 0
    FIELDS TERMINATED BY ";"
    MISSING FIELD VALUES ARE NULL
    REJECT ROWS WITH ALL NULL FIELDS
    "COUNTRY" Char,
    "YEAR" Char,
    "PERIOD" Char,
    "ACCOUNT" Char,
    "DEPT" Char,
    "ACTIVITY_LOC" Char,
    "AMOUNT" Char
    LOCATION (IN_DIR:'total.txt')
    REJECT LIMIT UNLIMITED
    NOPARALLEL
    NOMONITORING;vr,
    Sudhakar B.

  • DecimalFormat bug (?) with scientific notation

    Hi there,
    i'm currently developing an application dealing with scientific notation of double values.
    When i was curious about forcing the DecimalFormat formatter to print an explicit sign character in the exponential part, i found this strange behaviour:
    Source code (example generated to show effect):
    import java.text.*;
    public class DecimalFormatBugTest {
    public static void main(String[] arguments) {
    DecimalFormat decimalFormat = new DecimalFormat("+0.00000E00");
    double testValue1 = 1.23456d;
    double testValue2 = 0.98765d;
    System.out.println("Test 1: " + testValue1 + " --> " + decimalFormat.format(testValue1));
    System.out.println("Test 2: " + testValue2 + " --> " + decimalFormat.format(testValue2));
    Output:
    Test 1: 1.23456 --> +1,23456E+00
    Test 2: 0.98765 --> +9,87650E-+01
    This is what i don't understand:
    The "workaround" with the explicit "+" in front of the whole format expression is already strange, but when the exponent turns negative, i have output like "E-+00" which is completly senseless.
    This output was generated using Java2 1.4.0 @ Win2k.
    Thanks for your comments!
    Greets, Marvin

    i have no clue why thats behaving that way but i can tell u another workaroun for doing what u want...
    I think u got to take that "+" sign off from the format u are giving while constructing the object DecimalFormat. Convert the result of decimalFormat.format(testValue1) into string and check for the character at 0. If its negative then prefix the result with '-' else with '+'.

  • Convert from scientific notation

    Can someone help me with this? I cannot get this working even using some of the tips I found on this site and elsewhere:
    Round this and format this with 2 decimals: '-2.58069E-11'.
    Now I realize this would end up -2.58, but it is giving me an error instead.
    Error converting data type varchar to numeric.
    SELECT CAST('2.58069E-11' AS NUMERIC(24,2))
    SELECT CAST('2.58069E-11' AS NUMERIC(24,12))
    I tried 12 just to make sure that there was enough room for the decimals
    If I use ISNUMERIC, it returns 1, so SQL Server considers it a number (at least with that function)
    The next example works, but it is not what I want.
    SELECT CAST('2.58069E-11' AS REAL) just returns the same thing with the 'E', (as REAL, of course)
    In these example I haven't done the rounding yet.
    I get all kinds of negative and positive numbers with different decimal lengths, but the scientific notation is particularly tricky.

    Before I put this to bed, I have found out both the above solutions are wrong when using a regular decimal:
    Try this:
    SELECT CAST(CAST('-1131658.27' AS REAL) AS NUMERIC(24,2))
    And this:
    SELECT CAST(CONVERT(REAL, -1131658.27) as DECIMAL(24,12))
    They both yield -1131658.25, and -1131658.250000000000, respectively.
    This is probably some floating point error, but how do I take care of it?

  • Scientific notation doesn't display correctly

    Hi, this is just a general question but it's about the Calculator app. The problem is with displaying answers in scientific notation. When I'm in scientific calculator mode, answers displayed on the screen only appear in scientific notation when they are larger than the number of digits that can be displayed. However, whenever I use it to calculate something in which the answer is smaller than the set precision for the number of decimal places, it always gives 0 instead of scientific notation. For example, if I type a number such as 1E19 and press =, then the answer displays correctly as 1E19. However, if I type 1/1E19, and press =, then the answer simply shows up as 0 instead of 1E-19, which is the correct answer in scientific notation. So, it seems that the scientific notation in Calculator simply does not display negative exponents in the scientific notation (I know that I can type such numbers but for some reason, it cannot display them as answers). This is very annoying because I often work with very small numbers, not just very large ones. Is there any way that I can get the scientific notation to display negative exponents when I'm working with very small numbers and when the answer is smaller than the set number of decimal places?

    There are tonnes of possibilities and many websites with suggestions. I tried all sorts of these option (clear cache, clear cookies, anti-virus changes, page style options etc) with no success until eventually I accidentally changed my character encoding autodetect (firefox 6) from "off" to "universal" and everything is fine.

  • Importing data in scientific notation format

    Hi,
    I've got some data files produced by some ancient laboratory software. In the files, numbers are formatted like this:
    +7.60609E-02
    +8.18901E-03
    etc.
    When I import the data into Numbers, Numbers does not seem to recognize that the data points represent numbers, rather than strings (I can't create plots from the data, for example). If I edit the cells to prepend "=" to the entry, then Numbers evaluates the entry as if it were scientific notation (which is what I want), so that +7.60609E-02 becomes 0.760609. Is there a way to indicate to Numbers that the data I am importing is in scientific notation format, and should be treated as such? Because I'm not too excited about manually prepending "=" to everything.
    Thanks

    If the file is a comma separated values file, you have two choices:
    1) Make a Numbers sheet that is formatted the way you want it, including formatting the cells in the column to be scientific.  Drag the file from Finder and drop it on cell A1 of the table or, if not A1, the top-left cell of where you wantthe data to begin in the table, like maybe cell B2. Or,
    2) Open the CSV file with Numbers. After import, select the column of numbers and format it as scientific.

  • Calculator: removing scientific notation in results?

    This seems like it must be a bug or a corrupted app, but I'd just like to confirm: with the calculator in "basic" mode, dividing two numbers which only have one significant digit returns a result like so: 1/3000 = 0.000333 (the setting for decimal places seems to be irrelevant).
    However, changing either number to have more than one significant digit returns the result in scientific notation, like so: 1/3100 = 3.225806e-04.
    Can anyone else duplicate this or help me correct it? It's obnoxious to have to keep adjusting the numbers. And yes, I realize that means my math skills suck. Thanks in advance.

    Bumpty-bump. Can anyone at least confirm or deny? TIA.

  • Remove scientific notation in report

    I'm calculating a number and placing it in a comment box on a report. This works fine, but one of the numbers has decided to display in scientific notation (1.52666667e-3). The problem is that the comment box is not large enough to display the scientific notation and gives no indication of not fitting into the box. Instead I see 1.52666 with no indication of the exponent. I'd much rather see .001527 however I don't want to force a STR format with "d.dddddd" because most numbers don't need this much precision and I'd probably run into errors for numbers such as 12345 which won't fit into the comment box with forced 6 digit precision. If I can force it out of scientific precision, it'll probably be fine.
    BTW: is there a certain number range where scientific notation becomes the default? If I knew this range I could then force the format with the STR function to display the way I want. e.g. IF x>-001 and x<.001 then STR(X,"d.dddd")
    Either method would probably work for me.
    thanks,
    James
    Solved!
    Go to Solution.

    MyVar is a 2 dimensional pointer (Channel Group, Channel) to numeric channels that meet some criteria.
    change box size: I had to make the box 3 times the width to display the number correctly. It shows 1.27933333333333E-03*. I'm appending the "*" to show the field is calculated instead of unadultered from the .csv. Maybe the problem isn't that the number is small, but that it's infinitely repeating. The number is calculate from the values .001919 - abs(.001919)/3
    Left Justify: no difference from right justify.
    Autoadj: shows 1.28E-
    I'm making a column of channels on the report, that's why the comment text is being set multiple times.
    Humphreyy - thanks for your ideas and help.

  • Scientific notation in numeric fields

    I need to be able to input scientific notation in numeric fields for my adobe forms.  I can put the pattern to num{9.99E} and it will allow me to put positive exponents and negative exponents to -3.  However, I need to input the number 4.76E-19 and it always changes it to 0.00E0.  What kind I do to keep this small of a number as 4.76E-19?

    Hi,
    Unfortunatly in approach with text field numbers will not be formatted in scientific  notation, users will have to type numbers in correct format.
    In approach with NumericField and patter {9.99E} i think there is some bug.
    I can type this number:
    After i lost focus from this field it will be formatted in tis style:
    And sfter button click i will get this:
    For big values everything working fine.
    Is this bug!?
    BR

  • Maybe you are looking for

    • Calling a method in a class extended from thread

      I'm trying to use two threads of type ThreadTest to call the addNum method in the class below. I found that i couldnt call the addnum method with the instances I created but had to make the addnum method static and then call it with the class name Th

    • Manipulating "Exclude from XML Output" property at runtime

      Hi ! Here's one for reports 10g Is there a way/function to manipulate the "Exclude from XML Output" property for attributes at runtime (say, in the after param form trigger ?) The srw.package contains functions to manipulate the "other 4" XML propert

    • IDM Provisioning with Pending status value

      Dear All, I'm trying to provision roles by setting up a workflow where the manager of the user need to approve before the role is assigned to the user. I have created a Business role and assigned priviliges to the BR. I also tried directly assigning

    • Oracle Text

      Hi Expert, how can i use the Oracle text to do searching with the XML documents? as i shredded the xml documents into the SQL view already, i cannot create index onto those views. what can i do with the Oracle text search? THX a lot~! Edith

    • Migration Issue - Workbook with VBA

      Hello Gurus, I have an issue while upgrading the 3.X workbook with VBA to 7.X.The Underlying queries are migarted to 7.X and I migrated the WB and ran it in 7.X. I found out the Macros was not running. When I debugged the VBA macros I found out the Q