About Number Data type

Hi All,
I have few issues with "Number" data type
1) trying to convert string "0.0000007" to Number i am getting value with exponential (1e-7). This is only when we have more than 5 0's after decimal.
2) If i try to do below calculation, i am not getting exact value:
ex: 999999.999999+999999999999=1000000999999-999999999999 = 1000000(expected should be:999999.999999)
0.3*6=1.79999998 (exact value: 1.8)
Please let me know what might be the issue......
Thanks in advance to all....

That's standard behavior for floating point.  If you search the forum for
past discussions of floating point and Number you'll see explanations why.
To get displayable strings, use toPrecision or toFixed

Similar Messages

  • Ho to Comapre with Number Data Type

    hi
    My reqt is to do validation in ValidateEntity Method.
    How to compare the with Number Data type:
    For ex: Number a = gatAbc();
    If(a>10)
    throw new oaExcption...
    But while comapring i got compiler Error
    Error(218,17): method >(oracle.jbo.domain.Number, int) not found in class abc.oracle.apps.per.irc.pqr.schema.server.XxabcEOImpl
    So plz tell me how to compare the integer value with Number data type
    Thanx

    Check with float. It will work definitely.
    float number = Float.parseFloat(HrsPerDay); //HrsPerDay is a String and I am converting it to float
    if(( number <= 0) || (number >= 21))
                            throw new OAAttrValException(OAAttrValException.TYP_VIEW_OBJECT,
                                              "xxCopyResourceVO1",
                                              rowi.getKey(),
                                              "NoOfCopies",
                                              rowi.getAttribute("NoOfCopies"),
                                              "PA",
                                              "xx_xx_COPY_POSITIVE_NUM");
                       }Here in this code i am also checking that the Hours cannot be less then 0 and greater than 20.
    Thanks
    --Anil                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Data_length of number data type

    when I checked for the columns with data type as number in dba_tab_cols it is showing 22 for all the columns irrespective of the precision and scale. why is it so?
    also can you tell what data length exactly means?
    Edited by: user12288160 on May 19, 2010 3:04 AM

    Hi tom,
    I am doing database sizeing. I am expecting that one of my table will have 50,000,000 records in
    future(say within 6 month). That table has composite primary key(5 columns). All the columns are
    NUMBER data type. In All_tab_column I could see the data length is always 22. So I tried to
    decrease the length( Number(10)). Then also its saying data length is 22. But I Know that I can't
    enter data in this field more than 10 digits. So In this case it should be 12. But why its showing
    22(Data_length field in All_tab_columns).
    My question is, for my sizeing calculation, should I take this length 12 or 22?.
    Thanks
    Followup August 12, 2004 - 9am Central time zone:
    that is the max length -- numbers are stored as varying length character strings.
    Source: http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1619552483055
    REgards
    Asif Kabir

  • NUMBER Data type's Negative Scale

    This is what I read in the 1z0-051 Study Guide:
    The NUMBER data type may optionally be qualified with a precision and a scale. The precision sets the maximum number of digits in the number, and the scale is how many of those digits are to the right of the decimal point. If the scale is negative, this has the effect of replacing the last digits of any number inserted with zeros, which do not count toward the number of digits specified for the precision. If the number of digits exceeds the precision, there will be an error; if it is within the precision but outside the scale, the number will be rounded (up or down) to the nearest value within the scale. I am not sure if I understood this paragraph the correct way or not and hence this query:
    I created this table t1
    create table t1
    (col1 number,
    col2 number(4),
    col3 number(4,2),
    col4 number(4,-2));
    INSERT INTO T1 (COL4) VALUES (1234); = 1200 is inserted
    INSERT INTO T1 (COL4) VALUES (12.34); = 0 is inserted
    INSERT INTO T1 (COL4) VALUES (12345.34); = 12300 is inserted. Should is not throw an error as the whole value should be of length 4 (including the precision).
    However, INSERT INTO T1 (COL4) VALUES (123456789.34); throws error.How is this working? Please help!
    Edited by: TuX4EvA on Sep 29, 2009 4:12 AM

    Please, observe the following example:
    CREATE TABLE test1
    col1 NUMBER (6, 2),
    col2 NUMBER (6, -1),
    col3 NUMBER (6, -2),
    col4 NUMBER (6, -3)
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (1234.89, 1234.89, 1234.89, 1234.89);
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (1000.89, 1000.89, 1000.89, 1000.89);
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (2020.02, 2020.02, 2020.02, 2020.02);
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (56, 56, 56, 56);
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (56.89, 56.89, 56.89, 56.89);
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (20.89, 20.89, 20.89, 20.89);
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (49.89, 49.89, 49.89, 49.89);
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (50.89, 50.89, 50.89, 50.89);
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (501.89, 501.89, 501.89, 501.89);
    INSERT INTO test1 (col1, col2, col3, col4) VALUES (158.23, 158.23, 158.23, 158.23);
    COMMIT;
    SELECT * FROM test1;When you select from the table, you will receive:
            col1          col2         col3     col4
       1234,89           1230           1200     1000
       1000,89           1000           1000     1000
       2020,02           2020           2000     2000
            56             60            100     0
         56,89             60            100     0
         20,89             20              0     0
         49,89             50              0     0
         50,89             50            100     0
        501,89            500            500     1000
        158,23            160            200     0From this example and according to the oracle documentation SQL Reference one could see that scale equal to -1 means to round the precision to the tens, -2 means to the hundreds, -3 - to the thousands and so on. But I cannot say it as well as it is said on page 44 from [Oracle Database SQL Reference|http://download.oracle.com/docs/cd/B19306_01/server.102/b14200.pdf].
    Hope it was useful :)

  • What is the size of number data type.

    what is the size of number data type (in term of memory storage ;byte ).
    Does it make different in size if mention number(38,0)?
    Thanks all in advance...:)
    Edited by: user10648897 on Jan 7, 2009 6:43 AM

    NUMBER (p,s)
    Number having precision p and scale s. The precision p can range from 1 to 38. The scale s can range from -84 to 127.number(38,0) = number(38)
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14196/schema002.htm#sthref472

  • Number data type and schematool kodo2.3.3

    Hi!
    I have a class that has a data member of type 'Number' (java.lang.Number).
    When I run the 'schematool' to generate the tables in the datastore, it
    seems to ignore this Number field. If i change the type to Integer or
    Float, and then run schematool, a corresponding column is correctly
    created in the table in the database. Is there anything special that needs
    to be indicated in the metadata file for Number data types?
    Thanks
    Vijay

    I have a class that has a data member of type 'Number' (java.lang.Number).
    When I run the 'schematool' to generate the tables in the datastore, it
    seems to ignore this Number field.It's pretty strnage, but the Number type isn't mentioned as a supported
    persistent type in the JDO specification, and so Kodo doesn't yet support
    it. I say it's strange because as you pointed out, all concrete subclasses
    of Number are supported: Integer, Float, Double, BigDecimal, BigInteger,
    etc.
    We recently realized this oversite ourselves, and so supporting Number fields
    is on our to-do list. For the time being, however, you're stuck with
    declaring the field to be some conrete type.

  • How to handle NUMBER data type of SQL

    Hello All,
    I have to call an Oracle store procedure developed by 3rd party, it has once of the input parameter as NUMBER.
    Since NUMBER SQL data type is not support by PI 7.0 (http://help.sap.com/saphelp_nwpi71/helpdata/EN/44/7b72b2fde93673e10000000a114a6b/content.htm),
    when I am execute this scenario, it through an error for - Unsupported parameter type 'NUMBER'.
    I cannot change the store procedure or any thing in Oracle.
    I gone through some thread but did not find any help. NUMBER type for Oracle SP
    Please let me know if there any work around.
    Thanks in Advance.
    Pradeep

    Thanks for your reply.
    I cannot customize the stored procedure parameter to NUMERIC, as this is standard SP is from a product.
    Below is the final XML generated with error on PALC and PREL parameter for NUMBER, ideally it should be
    <PALC isInput="true" type="NUMBER"/>
    <PREL isInput="true" type="NUMBER"/>
    <Statement xmlns="">
    <LSA_REL_DM action="EXECUTE">
        <table>ACQDR.lsa_rel_dm</table>
          <PPROJECTID isInput="true" type="VARCHAR">85LJ24210</PPROJECTID>
          <PDMC isInput="true" type="VARCHAR">LJ200-A-J00-00-00-00-00AAA-00K-AA</PDMC>
          <PLCN isInput="true" type="VARCHAR"/>
          <PALC isInput="true"/>     
          <PTYPE isInput="true" type="CHAR"/>
          <PSOURCE_CODE isInput="true" type="VARCHAR"/>
          <PREL isInput="true"/>     
          <PRFU isInput="true" type="VARCHAR"/>
          <POBJECT isInput="true" type="BLOB">&lt;dmodule xsi:noNamespaceSchemaLocation="C:/Projects/S1000D/Document/schema/TIR_Parts_Vendors.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;identAndStatusSection&gt;&lt;dmAddress&gt;&lt;dmIdent&gt;&lt;dmCode modelIdentCode="LJ200" systemDiffCode="A" systemCode="J00" subSystemCode="00" subSubSystemCode="00" assyCode="00" disassyCode="00" disassyCodeVariant="AAA" infoCode="00K" infoCodeVariant="A" itemLocationCode="A"/&gt;&lt;language languageIsoCode="US" countryIsoCode="sx"/&gt;&lt;issueInfo issueNumber="0" inWork="1"/&gt;&lt;/dmIdent&gt;&lt;dmAddressItems&gt;&lt;issueDate year="20111107" month="20111107" day="20111107"/&gt;&lt;dmTitle&gt;&lt;techName&gt;General&lt;/techName&gt;&lt;infoName&gt;Organizations technical information repository&lt;/infoName&gt;&lt;/dmTitle&gt;&lt;/dmAddressItems&gt;&lt;/dmAddress&gt;&lt;dmStatus&gt;&lt;security securityClassification="01"/&gt;&lt;responsiblePartnerCompany enterpriseCode="24210"&gt;&lt;enterpriseName&gt;Learjet&lt;/enterpriseName&gt;&lt;/responsiblePartnerCompany&gt;&lt;originator enterpriseCode="24210"&gt;&lt;enterpriseName&gt;Learjet&lt;/enterpriseName&gt;&lt;/originator&gt;&lt;applicCrossRefTableRef&gt;&lt;dmRef&gt;&lt;dmRefIdent&gt;&lt;dmCode modelIdentCode="LJ200" systemDiffCode="A" systemCode="J00" subSystemCode="0" subSubSystemCode="0" assyCode="00" disassyCode="00" disassyCodeVariant="A" infoCode="00W" infoCodeVariant="A" itemLocationCode="A"/&gt;&lt;/dmRefIdent&gt;&lt;/dmRef&gt;&lt;/applicCrossRefTableRef&gt;&lt;brexDmRef&gt;&lt;dmRef&gt;&lt;dmRefIdent&gt;&lt;dmCode modelIdentCode="LJ200" systemDiffCode="A" systemCode="J00" subSystemCode="0" subSubSystemCode="0" assyCode="00" disassyCode="00" disassyCodeVariant="A" infoCode="022" infoCodeVariant="B" itemLocationCode="D"/&gt;&lt;/dmRefIdent&gt;&lt;/dmRef&gt;&lt;/brexDmRef&gt;&lt;/dmStatus&gt;&lt;/identAndStatusSection&gt;&lt;content&gt;&lt;techRepository&gt;&lt;partRepository/&gt;&lt;/techRepository&gt;&lt;/content&gt;&lt;/dmodule&gt;</POBJECT>
            <PSTATUS isInput="true" type="CHAR">D</PSTATUS>
            <PISSTYPE isInput="true" type="CHAR"/>
            <POBJECT_CLASS isInput="true" type="VARCHAR">XML</POBJECT_CLASS>
        </LSA_REL_DM>
    </Statement>
    Thanks in Advance

  • Loading unpacked Zoned data into NUMBER data types

    I need to use SQL*Loader to load data created on an MVS machine (EBCDIC) which is FTP'd to AIX (converted to ASCII during the FTP). Some of the data elements have signed unpacked numeric data. These need to be loaded into two types of fields in Oracle - 1) defined as data type NUMBER(19) 2) - defined as data type NUMBER (38,2) (i.e. dollar field with 2 decimal positions). For the dollar data I am loading there is an implied decimal. I need to know how to code SQL*Loader statements to handle these two situations. Because I have zoned unpacked source the resulting data loaded into the table must have a trailing sign (only if negative). Also the dollar fields need to have an explicit decimal inserted - and these dollar fields could also end up being negative.
    Any help would be appreciated. Various google searches have not given me the answers I need.

    979755 wrote:
    Most helpful. Pardon a few follow-on questions:
    1. The Zoned definition refers (I hope) to the data on the input file - regardless of the definition of the field field being loaded in the table (in my case the field in the table is defined as NUMBER) - is this a true statement?
    True, in your controlfile you set (for example): , zonedCol POSITION(x:y) ZONED(precision,scale)
    2. If I am correct on item 1, if I have a negative number in the input file (let's say a negative 10) is a trailing sign loaded into the database (so it will be 10-)?
    NO, to deal with signed numbers, you set trailing signs as table column in a staging table and then apply to real table.
    3. What happens to any leading zeroes when the data is loaded into the table?
    Ignored.
    4. For dollar fields where the source has an implied decimal but I want an implicit decimal in loaded into the table and the number can be positive or negative, can I specify this as ZONED (10.2) in the control file?
    See answer #2.
    ZONED (10,2) implies field is 10 characters long and the last two are decimals.
    5. And finally, regarding item 4 my understanding is that ZONED (10.2) would result in 12345678.12 (with a negative sign if appropriate) - is this a correct understanding?
    Nope, only the digits. That is why we use staging table to capture the sign.
    PS: The best would be to create external table on the source file.
    Edited by: L-MachineGun on Jan 4, 2013 3:12 PM

  • About string data type

    Hi
    Maximum number of characters that a string data type accepts in Java.
    Thanks..

    The next may give a rough test.
    public static void main(String[] args) throws Exception{
    int factor= Integer.parseInt(args[0]);
    char[] data = new char[Integer.MAX_VALUE/factor];// note: integer division
    for(int k=0;k<data.length;k++)  data[k]=(char)0x30;
    String s=new String(data);
    System.out.println(Integer.toString(s.length()));
    }

  • Table Functions, Direct Database Requests, and NUMBER data types

    Hello. I call a number of table functions from our BI Enterprise server, and I've elected to do so using Direct Database Requests (I believe you can also call table functions in the physical layer of the repository, but that's not what I'm doing). The problem is that whenever I return any number from the table function that is not a whole number (1.23, for example), BI assigns the INTEGER datatype to the field instead of the DOUBLE datatype, thereby rounding my number to the nearest integer. Here's a concise example:
    Create these 3 database objects:
    CREATE OR REPLACE TYPE my_row AS OBJECT (my_num NUMBER);
    CREATE OR REPLACE TYPE my_tab AS TABLE OF my_row;
    CREATE OR REPLACE FUNCTION my_table_function RETURN my_tab
    PIPELINED IS
    BEGIN
    PIPE ROW(my_row(1.23));
    END;
    Then make this your query in your Direct Database Request:
    SELECT my_num FROM table(my_table_function);
    That query correctly returns "1.23" when it's called from the database. In BI, on the other hand, it returns "1" (and labels the field an INTEGER instead of DOUBLE data type). If in the Direct Database Request you change the Column Properties ->Data Format -> Decimal Places from 0 to 2, it then not surprisingly displays "1.00". I then tried changing MY_ROW.MY_NUM's datatype by explicitly specifying precision, and no luck. BI still labels this field as an INTEGER. Then I started trying to trick BI by massaging the SQL statement itself. None of the following worked:
    SELECT to_number(my_num) as my_num2 FROM table(my_table_function);
    SELECT my_num2 + 0.01 as my_num3 FROM (SELECT my_num - 0.01 AS my_num2 FROM table(my_table_function));
    SELECT to_number(to_char(my_num)) as my_num2 FROM table(my_table_function);
    SELECT to_number(substr(to_char('x'||my_num),2)) as my_num2 FROM table(my_table_function);
    Now I did find a solution, but I'm surprised that I have to resort to this:
    SELECT * FROM (SELECT /*+ NO_MERGE */ my_num FROM table(my_table_function));
    Does anyone out there know of a better way to do this? The above is a hack in my opinion. :)
    Thanks in advance for any input.
    -Jim

    Yes, it's really amazing.
    But I got it.
    CREATE OR REPLACE TYPE my_row AS OBJECT (my_num NUMBER(10,2));and in your SQL :
    SELECT cast(my_num as double precision) as my_num2 FROM table(my_table_function);I have the good result and I see the numbers after the comma.
    Very tricky !
    Edited by: gerardnico on Jul 7, 2009 2:55 PM change number(10,2) by double precision ......... pfffff

  • Number data-type saving problem through PL/SQL

    hi,
    I am having a field in my table called "amount" with type number(17,3). I am facing some problem while saving the data through pl/sql developer.
    while i am inserting data like 123456789012.567 its working fine but when I am inserting 1234567890123.567 for amount field its now showing any error while saving, but actually its storing "1234567890123.570" in DB. Similar thing is happening when I was saving "12345678901234.567",actually its saving "12345678901234.600".
    Whenever I was getting for 17 digits it's rounding last 3 and for 16 its rounding 2.
    I am using oracle10g as DB server.
    please suggest how to solve this particular problem as i am stuck or the alternate ways...
    Thanks,
    Shouvik

    It is a display problem, not a storage problem. i'm not sure what the equivalent in PL/SQL Developer is, but this sqlplus example seems to replicate your stated issue.
    SQL> create table t (num number(17,3));
    Table created.
    SQL> insert into t values (123456789012.567);
    1 row created.
    SQL> insert into t values (1234567890123.567);
    1 row created.
    SQL> insert into t values (12345678901234.567);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> set numwidth 16
    SQL> select * from t;
                 NUM
    123456789012.567
    1234567890123.57
    12345678901234.6
    SQL> set numwidth 25
    SQL> /
                          NUM
             123456789012.567
            1234567890123.567
           12345678901234.567You need to expand the display width for numbers.
    John

  • Migrate SqlServer BigInt DataType to Ora Number data type - customizable ?

    Hello,
    i'm trying to migrate a sql-server 2005 db to oracle 10 using Sql-Developer v 1.2.0.
    Every column having datatype bigint is converted to a Number(10,0) column.
    Is it possible to customize this convertion cause i would like to have a Number(19,0) column ?
    Thanks in adavance !

    SQL> desc emp_test;
    Name                                                                                Null?    Type
    EMPNO                                                                                        NUMBER(6)
    ENAME                                                                                        VARCHAR2(20)
    JOB                                                                                          VARCHAR2(9)
    MGR                                                                                          NUMBER(4)
    HIREDATE                                                                                     DATE
    SAL                                                                                          NUMBER(7,2)
    COMM                                                                                         NUMBER(7,2)
    DEPTNO                                                                                       NUMBER(2)

  • About Generic data type

    LinkedList<Integer> i=new LinkedList();
    How is it compile properly ?

    Mrjavan wrote:
    No everything is run properly.Yes, but the compiler gives you a warning about the third line:
    $ javac Foo.java
    Note: Foo.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    $ javac -Xlint:unchecked Foo.java
    Foo.java:8: warning: [unchecked] unchecked conversion
    found   : java.util.HashMap
    required: java.util.HashMap<java.lang.Integer,java.lang.String>
        HashMap<Integer,String>hmap3=new HashMap();
                                     ^
    1 warning
    $To summarize:
    In the first line, you declare the full parameterized type in the instanciation, but discard it because your variable only has the raw type. So you're doing useless work.
    In the second line you declare the full parameterized type in both the variable declaration and the instanciation. That's the correct way. Now the compiler can check access to hmap2 for type correctness.
    In the third line you declare the full parameterized type in the variable declaration, but use a raw type for the instanciation. Here the compiler gives you a warning that it can't check the assignment at runtime. Don't do that.
    Note that at runtime all 3 will behave exactly the same, because of type erasure (google that term).

  • Adding scale to a number data type

    I have a current column that is Number(22) that has many rows in it. I would
    like to keep the 22 and add 2 to the scale, can this be done on the fly????

    Why not try
    ALTER TABLE a MODIFY num_col NUMBER( 24, 2);
    and see what happens. If it works you are done. If not add a column number(24,2), update the table to set the new column = to the old column, alter that table to drop the old column, alter the table to rename the new column to the old columns name. Or set the old column null, modify it, update back to it from the new column, then drop the new column, or use DBMS_REDEFINITION.
    It is well to try something before coming here for a solution. Then tell us what you have tried and the results.

  • I have a question about the data type static

    for any of you that read my last post for my assignment this is still the same thing but i have broke it down more, but i am getting an error and i am not for sure i understand why that is. I think i am confused on why i should, or could use a static?
    thanks again guys
    package wordstester;
    import javax.swing.JOptionPane;
    * @author christopher izatt
    public class WordsTester {
         * @param args the command line arguments
        public static void main(String[] args) {
                  // prompt the user to enter a string of their choice
          String wordChosen;
          wordChosen = JOptionPane.showInputDialog
              ("Please enter a word of your choice here");
          String middlePart;
          middlePart = Words.getMiddle(wordChosen);      <----- error nonstatic method can not be referenced in a static context
          System.out.println("At the middle of " + wordChosen + " is: "
                     + middlePart);
    package wordstester;
    * @author christopher izatt
        public class Words {
        private String wordChosen;
        public String Words(String letters) {
            wordChosen = letters;
            return wordChosen;
        public String getMiddle(String wordChosen) {
            int letters = wordChosen.length() / 2;
            int endindex = letters +1;
            return wordChosen.substring(letters, endindex);
       

    Try this.
    Imagine a blueprint from which houses are constructed. The blueprint indicates that each house will have a garage, a roof, a front door, etc. However, each house will have its own roof - be it a tar shingle roof or a cedar roof or maybe thatch - but that's another issue.
    Now, in the lower left corner of the blueprint, we find the architect's name and company logo. That logo is part of the blueprint - each house will NOT have its own discreet copy of that item. Instead, each house will share the one and only copy of that logo.
    That's what static members are. They are called "class variables" or "class methods" and are accessed through the class name instead of an object name.
    I hope that helps.

Maybe you are looking for

  • Using the DBMS_XDBRESOURCE PL/SQL package

    Does anyone know how to use the functions in the DBMS_XDBRESOURCE package? I've tried to use the GETCREATIONDATE function but no luck. I usually get a "PLS-00221: 'GETCREATIONDATE' is not a procedure or is undefined" The 11g PL/SQL packages and type

  • Authentication, Multiple domain,different forest lowercase domain.

    We have succesfully configured a BOXI 3.1 SP3 to use SSO using vintela,tomcat for our domain that is on 2000 native mode. Let's call this one Domain1. In our domain there is another separate domain sitting on a 2003 domain level. (Let's call this one

  • Some doubts regarding APD

    Hi Friends, I am working on APD for the first time. While working on it, I came across the following doubts/questions: 1. If we have created a query as the source for APD and transactional ODS as target in Dev. Now, I want to transport this APD in QA

  • TreeMap.put() Problem

    I am having a problem with adding different types of objects as keys to a TreeMap, although the javadoc says that the method takes two arguments of type object, I am getting a casting error when I try the following. TreeMap matched = new TreeMap(); m

  • Download InDesign CC in different language version

    Hello, I am a complete creative member in the UK. Can I download and use InDesign CC Japanese version?