Float/double data types

I use
public void setId(float id) {this.id = id;}
and
setId(new Float(nodeNextTop.getChildNodes().item(0).getNodeValue()).floatValue());
in my java files to get the value of a float which I want to display using
<display:column align="center" sortable="true" nowrap="true" property="id" title="<%=id_%>" class="webText" />
in my jsp file
but it is displayed in true E format, ie, 1.123456789101112E15, I want to display the number as is, without the E, and it's beaten me, pls help.
btw, double does the same

top job, I'm learning something new each day, big thnx for the help

Similar Messages

  • Error ORA-01426: numeric overflow when Creating table with double data type

    Hi,
    I am using ODP.NET to create a table with data from SQL to Oracle. The problem is with double data type fields that is equivalent to FLOAT(49) in Oracle. My syntax is:
    CREATE TABLE SCOTT.ALLTYPES
    F1 NUMBER(10),
    F10 DATE,
    F2 NUMBER(10),
    F3 NUMBER(5),
    F4 NUMBER(3),
    F5 FLOAT(23),
    F6 FLOAT(49),
    F7 NUMBER (38,5),
    F8 NVARCHAR2(500),
    F9 NVARCHAR2(500)
    Th error is with field F6 but I am not sure what is the correct type equivalent to double in SQL.
    I woul appreciate if anyone can help me with this problem.
    Sunny

    Does this simple test work for you?
    In database:
    create table float_test
      f1 float(49)
    );C# code:
    using System;
    using System.Data;
    using System.Text;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    namespace FloatTest
      /// <summary>
      /// Summary description for Class1.
      /// </summary>
      class Class1
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
          // connect to local db using o/s authenticated account
          OracleConnection con = new OracleConnection("User Id=/");
          con.Open();
          // will hold the value to insert
          StringBuilder sbValue = new StringBuilder();
          // create a string of 49 number 9's
          for (int i = 0; i < 49; i++)
            sbValue.Append("9");
          // command object to perform the insert
          OracleCommand cmd = con.CreateCommand();
          cmd.CommandText = "insert into float_test values (:1)";
          // bind variable for the value to be inserted
          OracleParameter p_value = new OracleParameter();
          p_value.OracleDbType = OracleDbType.Double;
          p_value.Value = Convert.ToDouble(sbValue.ToString());
          // add parameter to collection
          cmd.Parameters.Add(p_value);
          // execute the insert operation
          cmd.ExecuteNonQuery();
          // clean up
          p_value.Dispose();
          cmd.Dispose();
          con.Dispose();
    }SQL*Plus after executing above code:
    SQL> select * from float_test;
            F1
    1.0000E+49
    1 row selected.- Mark

  • Issue in trusted flat file recon for usr field having double data type

    Hi
    I have a field in usr schema which is of double data type. Now when i am doing gtc trusted flat file recon the user is getting created and all fields are getting populated but field having double data type doesn't get populated.
    I have tried in other way also. After creating the user, I am trying to update that field (which is of double data type) via gtc trusted flat file update but in that case no recon event is getting generated.
    Enviroment : OIM 11.1.1.5.0
    I am stuck. Please help.

    Somebody PLEASE some idea!!!
    Any thought on the same would be really appreciated.
    Thanks in advance.

  • Java rounding for Double data type

    Hi,
    Is there a way to change the default precision to 2 digits after decimal point for Double data type.

    java.text.DecimalFormat:
    import java.text.DecimalFormat;
    DecimalFormat format = new DecimalFormat("#.00");
    StringBuffer formatted = format.format(Math.PI, new StringBuffer(), new FieldPosition(0));
    System.out.println(formatted); // prints out 3.14Probably as applicable today as it was 3 years ago

  • Arithmetic Overflow error converting float to data type numeric

    Hi,
    Am facing strange issue,I have function which returns money datatype and assigning the return money value to float datatype in table.
    Error msg:
    Msg 8115, Level 16, State 6, Procedure GBCalcCatalogPriceNewV2, Line 204
    Arithmetic overflow error converting float to data type numeric.
    The statement has been terminated.
    Strange thing is the same stored procedure is working fine in production environment,but in the deveopment i see this error.Am scared if the same happens in the production environment.Please advice and advance
    thanks
    Regards
    RAj

    Strange thing is the same stored procedure is working fine in production environment,
    How could that be strange? This is an error that occurs depending on the data. Accidents that are waiting to happen will happen sooner or later.
    Then again, a development database may be more prone to such errors, because data that entered are completely out of whack with real life data. Still it is a warning sign. If you have some place where you convert data from float to numeric, you must consider
    the risk that the float value is outside the range for the numeric data type. How do you prevent that from happening? Maybe a CHECK constraint on the column? Of if the data origins from a money column, use a numeric data type with sufficient precision.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Mapping Float with data type Qty or Curr or INT4

    Hi,
    We are extracting the data from a table. Some fields are defined as Float but at trasfer rules we have mapped those Key figures with Quantity or Currency or INT4 .
    In transfer rules there is only info object mapping. But when extracting the data we are not getting any data even In PSA for those fields.
    Please suggest should we change the data type or any changes
    Thanks,
    Shaliny. M

    Hi,
    Can you provide some more inputs.
    have you mapped with Standard Fields.
    Reg
    Pra

  • Pack  and Floating Point Data Type in ABAP

    Dear All,
    I am new to ABAP. Started with data types. Came across pack and floating point.
    Please let me know what PACK  and Floating Point stands for with few examples and the main difference between them.
    Regards
    Arun V

    Hi,
    You'd better ask this question in ABAP forum http://forums.sdn.sap.com/forum.jspa?forumID=50 .
    Best Regards,
    Ada

  • What is the match of float or double data type in abap?

    I have tried p, but I could not handle decimal numbers such as 10.6 or 10,6(no matter which one is preferred, the question is the same...).
    How can I handle these numbers?
    Thanks.

    Hi
    Hope you know about FLOAT and Double.But you can use the same P for handling decimal places...
    Use like this.
    Data :Deci type P DECIMALS 2.
    Get bckif you are getting error still...
    Reward All Helpfull answers..........

  • Re: Formatting a double data type

    See: http://javaalmanac.com/egs/java.text/FormatNum.html

    thnx, that solved my problem, But gave rise to another.
    When i have to display the result, I need in this format ##.00.
    This works fine for non zero values after the decimal point. If i ahve
    double d = 6.10;
    NumberFormat format = NumberFormat.getNumberInstance();
    System.out.println(format.format(d));
    The ideally i need it to display: 6.10, but it display only 6.1.
    I tried DecimalFormat too.. but couldnt find a solution. Please help.

  • Float/double implementation

    I am writing an application in J2ME and badly need a float/double data type, which J2ME does not have. I was wondering if anybody had some good ideas on how to implement a float/double data type using only ints.
    Thanks.
    AnjuM

    Use 2 longs, one for the 1's and one for the deciamal part. if the decimal part is over the max number you want to represent in decimal then subtract max from it and add 1 to the 1's side.
    If I wanted to show 9 decimal places, then anything past 999,999,999 should have 1,000,000,000 subtracted from it and 1 added to the left side.

  • Float data types

    I don't really know SSAS but have been a .NET programmer and worked with SQL Server and T-SQL for years.  I am working on a project where there is a database storing sales transactions and a cube that is created nightly so we can get MTD Sales, YTD
    Sales, Profit $, etc.
    I just ran into an issue where I got an error retrieving the Profit $ measure (using an MDX query inside of a SQL stored procedure using OPENQUERY) and found that the profit $ should be 0.07 but is coming back as 6.9999999999993179E-2. After talking
    to our DBA, he said all of the calculations in the cube are double precision floating point and I need to round all results to 2 decimal places (programs like Excel handle the rounding and I should too.)
    Our DBA also claims the measures can't be calculated and returned as currency. He claims that the potential for error is very small and no one has ever complained about a $ value being off.
    I am struggling with this answer because I have always been told never to use floating point for monetary values.  I am having a hard time believing there is no way to have a measure be a currency field that is accurate.  I looked for articles
    online but can't seem to find anything to answer my questions.
    Could someone please point me in the right direction? Thanks so much!

    Your DBA is not completely correct in his claims. All calculations are not floating point below is a link to all of the data types supported by SSAS (Multi-Dimensional)
    https://technet.microsoft.com/en-us/library/gg471558%28v=sql.110%29.aspx?f=255&MSPPError=-2147217396
    SSAS supports a currency data type. It's 4 decimal places not 2, but it is the recommended data type for currency values as it does not suffer from the imprecision of the double data type.
    The other thing measures in a cube have is the concept of a format string, so you can ask the cube to return a pre-formatted value to you. But default an OPENQUERY will just return the raw value, but if you add the following:
    CELL PROPERTIES FORMATTED_VALUE
    to the end of your MDX query that should tell it to return the formatted value (which could be something like "$#,##0.00")
    See here https://msdn.microsoft.com/en-us/library/ms146084.aspx for a list of all the different format masks that can be applied
    http://darren.gosbell.com - please mark correct answers

  • Getting precision length  for float data type

    Hi All,
    We trying to find the precision length of a float (126) data type. Are there any built in functions in oracle for finding the same? E.g: the function should return 5 for the value 1.23456 .
    Also, are there any table level operation to reduce the decimal precision of a float 126 field?
    Regards,
    Raj.

    Not sure if this is what you're looking for:
    select data_precision from all_tab_columns
    where owner = '<your schema name>'
    and table_name = '<your table name>'
    and column_name = '<name of column in table>';
    or are you looking for a particular find_precision_in_number() function...
    i can't think of one off the top of my head, but you can always do:
    length(substr(<colname>, instr(<colname>, '.')+1))

  • Float - double == loss of accuracy?  why?

    The following test fails:
    public void testFloat() {
            float number = 46702.45F;
            Float numberAsFloat = new Float(number);
            double numberAsDouble = numberAsFloat.doubleValue();
            System.out.println(numberAsDouble);
            assertTrue(46702.45 == numberAsDouble);
    }I probably just don't understand floating point data types or something, but I was very surprised that this test fails. If someone could enlighten me on WHY this fails, I would really appreciate it. For what it's worth, the value printed out for numberAsDouble was 46702.44921875 which I find entirely unexpected considering I am going from a lower precision data type (float) to a higher precision data type (double).

    Remember: the floating point representations (float and double) store binary values. Not decimal. The decimal values are parsed by the compiler and turned into floats and doubles in binary.
    The said binary values are approximations to the decimal values. Sometimes the binary and the decimal values coincide, but some times they don't.
    Floats have less precision than doubles.
    The binary string that represents that number, in a float, will be interpreted differently in a double, because the double has those additional bits of precision.
    Consider this code:
        double nd = 46702.45d;
        float nf = 46702.45F;
        long ndl = Double.doubleToLongBits(nd);
        long nfl = Float.floatToIntBits(nf);
        long nfl2 = Double.doubleToLongBits(nf);
        System.out.println(Long.toBinaryString(ndl));
        System.out.println(Long.toBinaryString(nfl));
        System.out.println(Long.toBinaryString(nfl2));It prints this:
    100000011100110110011011100111001100110011001100110011001100110
    1000111001101100110111001110011
    100000011100110110011011100111001100000000000000000000000000000
    // now I add spaces to line up the various segments
    // sign   exponent  mantissa
         1 00000011100  110110011011100111001100110011001100110011001100110
         1    00011100  1101100110111001110011
         1 00000011100  110110011011100111001100000000000000000000000000000Look at that string of "0011"'s on the version of the number created as a double.
    Compare it to the 0's in the version that was created as a float and used as a double.

  • Float/double confusion

    Could someone explain the theory behind the following:
    The default floating point data type is a double, hence the following declaration will not compile:
    float f=1.3;
    However the following declaration will compile:
    float f=1/3
    ...without specifying that it should be a float. Why does this happen, and why is the resulting value in f 0.0? Surely it should be 0.3333 or similar?

    1/3 is the integer 1 divided with the integer 3, and since they both are integers it would be natural for the result to be integer too, and so the division performed is called integer division. And the integer 0 is the result because one third is doesn't fit any integer. The fractional part is clamped. This result is then implicitely casted to produce the float 0.0f.
    Why? Because that's the way it goes in C and C++.

  • Few questions - game loop, data types, speed

    Hello, I have a few questions after studying some topics in this forum regarding game creation:
    1) What's the fastest way to wait in the game loop? I've seen two approaches:
    thread.sleep(10)andsynchronized(this) { wait(10); }2) What data types shall I use? In C++ I use to prefer int over short in all cases, because 32bit hardware works faster with integers. Is this same on cell phones?
    3) Speed of applications is slow. I just wonder wheter it's my fault. I was testing application, which only cleared the buffer and outputted FPS and I got around 20 frames. It was Nokia 6300 with 240x320 display. After testing on other phones I've found out that the bigger the resolution, the slower the game is going. Is this normal?
    Thanks for replies...

    1) You're not going to notice any really speed difference between the two code snippets. Read up on 'Threads', and you'll see why one may be used in place of the other depending on the situation. In general there may be a slight performance loss, however unnoticable, when using the synchronized version, but when you are multithreading it is likely necessary.
    sleep(int) is impossible to interrupt, so it's generally a no-no in most situations. However we are talking about devices where every bit of performance helps, so as long as it works for ya, it's not a big deal.
    2) The performance difference is fairly negligable, if any. The biggest thing to consider is memory requirements, and shorts take 1/2 the data.
    Also, many phones don't support floating point data types, so you'll likely need to use ints/longs to calculate your values if you want to have any accuracy beyond whole numbers. Doing something like shifting bits or using 1000x values in your calculations can get around most of the problems when you can't use floats.
    3) The biggest performance killers are IO, memory allocation, screen drawing; pretty much in that order. So I imagine that you are re-creating a new String object every time you output your FPS value on screen right? Doing that every frame would destroy any hopes of getting high-performance.
    Just be careful, and never allocate objects when you can avoid it. anything where you concat String objects using + will cause your performance to die a horrible painful slow death. Remove anything that says 'new' from your main loop, and all String operations, and it'll likely speed things up a lot for ya.
    Does your main loop have something like this?
    g.drawString("FPS: " + currentFps, 0,0,Graphics.TOP | Graphics.LEFT);
    This is very bad because of the String operation. It'll create a new String every frame.
    If you have any more specicif questions, or you'd just like to pick the brain of a mobile game dev, stop by my messageboard:
    http://attackgames.proboards84.com
    Message was edited by:
    hooble

Maybe you are looking for