Double value 'infinity' causes IllegalArgumentException

Trying to bind the value Double.POSITIVE_INFINITY in a prepared statement causes an IllegalArgumentException using ojdbc6 11.2.0.4.0 but it works fine in version 11.2.0.3.0:
Exception in thread "main" java.lang.IllegalArgumentException: Overflow
    at oracle.jdbc.driver.OraclePreparedStatement.setDoubleInternal(OraclePreparedStatement.java:7605)
    at oracle.jdbc.driver.OraclePreparedStatement.setDouble(OraclePreparedStatement.java:7513)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.setDouble(OraclePreparedStatementWrapper.java:494)
    at DoubleOverflow.main(DoubleOverflow.java:26)
Source:
import java.sql.*;
import oracle.jdbc.pool.OracleDataSource;
public class DoubleOverflow
  public static void main (String[] args) throws SQLException {
    OracleDataSource ods = new OracleDataSource();
    ods.setUser(System.getProperty("DB_USER"));
    ods.setPassword(System.getProperty("DB_PASSWORD"));
    ods.setURL(System.getProperty("JDBC_URL"));
    Connection conn = ods.getConnection();
    PreparedStatement pstmtCreateTable = conn.prepareStatement("create table ojdbc6test (d BINARY_DOUBLE)");
    try {
        pstmtCreateTable.execute();
    } catch (Exception ex) {
        if (ex.getMessage().contains("ORA-00955")) {
            System.err.println("Test table already created - ignore SQL error and continue");
        } else throw ex;
    pstmtCreateTable.close();
    PreparedStatement pstmt = conn.prepareStatement ("insert into ojdbc6test (d) VALUES (?)");
    // This will cause an IllegalArgumentException in ojdbc6 11.2.0.4.0 but not in 11.2.0.3.0
    pstmt.setDouble(1, Double.POSITIVE_INFINITY);
    pstmt.execute ();
    pstmt.close();
    conn.close();
The database used is 'Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production'. I don't see any mention regarding changes to this in the 11.2.0.4.0 change log. Is this a bug in the driver or is there some other explanation?

Thanks -
Testing shows that the driver code was changed to check for underflow/overflow but doesn't appear to take the two INFINITY constant values into account properly.
Whether that was done INTENTIONALLY or not I don't know.
I suspect it is a bug in the new driver code.
If you have a MOS account you shouild submit a bug report to Oracle and include the example code you posted above.
I doubt if there is any workaround.

Similar Messages

  • How to solve NaN error, while dealing with multiplication of double values

    i am getting NaN error in the program.
    consider this following code
    for (j=0;j<nh;j++)
    sum = 0.0;
    for (i=0;i<ni;i++){ sum = sum + (ai[i] * wi[i][j]) ;}
    //System.out.println(sum);
    ah[j] = sigmoid(sum);
    public static float sigmoid(float x)
    return ((Math.exp(x)- Math.exp(-x)) / (Math.exp(x)+Math.exp(-x)));
    ni = 2500-- no of input nodes;
    nh = 5000 -- no of hidden nodes;
    i am getting problem in calculating the "sum" value. its returning NaN for "sum".
    here a[i] values are around some +/- 0.XXXXXXXX upto 14 digits
    and wi[j][j] values are also +/- 0.XXXXXX upto 14 digits.
    all values are of datatype double.
    i was stucked up with this problem. what i am to do?
    give me suggestions..
    please reply me

    This can occur with double divisions. I wrote a small method that solves this:
         * Set double values that have a value of 'NaN' or 'Infinity' to 0.0. This can happen when dividing double values as they
         * don't cause a DivisionByZeroException.
         * @param value Double value to check.
         * @return Input value with 'NaN' and 'Infinity' set to 0.0.
        static public double resetNaN(final double value, final double resetValue) {
            return (Double.isNaN(value) || Double.isInfinite(value)) ? resetValue : value;
        }//resetNaN()

  • OpenSQLException - Cannot assign double value

    Hello,
      I have some table in database with field of type 'double'. I use JDBC to store data in this table and sometimes I would like to place special values in it, eg:
    preparedStatement.setDouble(1, Double.MIN_VALUE);
    Unfortunately I get exception like the one below.
    My question is: what is the allowed range of values for type 'double' in database according to OpenSQL spec ?
    Thanks!
    Marcin Zduniak
      com.sap.sql.log.OpenSQLException: Cannot assign double value 4.9E-324 to host variable 3 because it is not in the allowed range of +/- to +/-.
        at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
        at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
        at com.sap.sql.jdbc.common.CommonPreparedStatement.setDouble(CommonPreparedStatement.java:534)
        at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.setDouble(PreparedStatementWrapper.java:281)
        at pl.com.bcc.hai.SpecificationBean0Persistent.ejb_iUpdate(SpecificationBean0Persistent.java:558)
        ... 42 more
    Full exception chain:
    com.sap.engine.services.ejb.exceptions.BaseEJBException: Transaction system failure in method pl.com.bcc.hai.SpecificationLocalLocalObjectImpl0.setTargetValue(java.lang.Double).
         at pl.com.bcc.hai.SpecificationLocalLocalObjectImpl0.setTargetValue(SpecificationLocalLocalObjectImpl0.java:4537)
         at pl.com.bcc.hai.conf.BCC_H_CConfig.setSTimeSeriesesAIM(BCC_H_CConfig.java:4129)
         at pl.com.bcc.hai.conf.wdp.InternalBCC_H_CConfig.setSTimeSeriesesAIM(InternalBCC_H_CConfig.java:1038)
         at pl.com.bcc.hai.conf.wdp.IPublicBCC_H_CConfig$ISTimeSeriesesElement.setAIM(IPublicBCC_H_CConfig.java:3651)
         at pl.com.bcc.hai.conf.wdp.IPublicBCC_H_CConfig$ISTimeSeriesesElement.wdSetObject(IPublicBCC_H_CConfig.java:3786)
         at com.sap.tc.webdynpro.progmodel.context.MappedNodeElement.wdSetObject(MappedNodeElement.java:365)
         at pl.com.bcc.hai.conf.wdp.IPrivateSpecificationEditor$ISTimeSeriesesElement.wdSetObject(IPrivateSpecificationEditor.java:1737)
         at com.sap.tc.webdynpro.progmodel.context.AttributePointer.setObject(AttributePointer.java:223)
         at com.sap.tc.webdynpro.clientserver.data.DataContainer.transportPendingUserInput(DataContainer.java:1267)
         at com.sap.tc.webdynpro.clientserver.data.DataContainer.transportPendingUserInput(DataContainer.java:474)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.transport(ClientComponent.java:548)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.transport(ClientComponent.java:552)
         at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.transport(ClientApplication.java:701)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.transportData(WebDynproMainTask.java:717)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.engine.services.ts.exceptions.BaseRollbackException: Exception in beforeCompletition of ( SAP J2EE Engine JTA Transaction : [1a55ffffffb01205ffffffd4ffffffdd] ).
         at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:232)
         at pl.com.bcc.hai.SpecificationLocalLocalObjectImpl0.setTargetValue(SpecificationLocalLocalObjectImpl0.java:4486)
         ... 35 more
    Caused by: com.sap.engine.services.ejb.exceptions.BaseEJBException: SQLException while the data is being flushed. The persistent object is pl.com.bcc.hai.SpecificationBean0Persistent.
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:101)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAll(TransactionContext.java:429)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flush(TransactionContext.java:378)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.beforeCompletion(TransactionContext.java:506)
         at com.sap.engine.services.ejb.entity.SynchronizationList.beforeCompletion(SynchronizationList.java:136)
         at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:220)
         ... 36 more
    Caused by: com.sap.sql.log.OpenSQLException: Cannot assign double value 4.9E-324 to host variable 3 because it is not in the allowed range of +/- to +/-.
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
         at com.sap.sql.jdbc.common.CommonPreparedStatement.setDouble(CommonPreparedStatement.java:534)
         at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.setDouble(PreparedStatementWrapper.java:281)
         at pl.com.bcc.hai.SpecificationBean0Persistent.ejb_iUpdate(SpecificationBean0Persistent.java:558)
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:80)
         ... 41 more
    com.sap.engine.services.ts.exceptions.BaseRollbackException: Exception in beforeCompletition of ( SAP J2EE Engine JTA Transaction : [1a55ffffffb01205ffffffd4ffffffdd] ).
         at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:232)
         at pl.com.bcc.hai.SpecificationLocalLocalObjectImpl0.setTargetValue(SpecificationLocalLocalObjectImpl0.java:4486)
         at pl.com.bcc.hai.conf.BCC_H_CConfig.setSTimeSeriesesAIM(BCC_H_CConfig.java:4129)
         at pl.com.bcc.hai.conf.wdp.InternalBCC_H_CConfig.setSTimeSeriesesAIM(InternalBCC_H_CConfig.java:1038)
         at pl.com.bcc.hai.conf.wdp.IPublicBCC_H_CConfig$ISTimeSeriesesElement.setAIM(IPublicBCC_H_CConfig.java:3651)
         at pl.com.bcc.hai.conf.wdp.IPublicBCC_H_CConfig$ISTimeSeriesesElement.wdSetObject(IPublicBCC_H_CConfig.java:3786)
         at com.sap.tc.webdynpro.progmodel.context.MappedNodeElement.wdSetObject(MappedNodeElement.java:365)
         at pl.com.bcc.hai.conf.wdp.IPrivateSpecificationEditor$ISTimeSeriesesElement.wdSetObject(IPrivateSpecificationEditor.java:1737)
         at com.sap.tc.webdynpro.progmodel.context.AttributePointer.setObject(AttributePointer.java:223)
         at com.sap.tc.webdynpro.clientserver.data.DataContainer.transportPendingUserInput(DataContainer.java:1267)
         at com.sap.tc.webdynpro.clientserver.data.DataContainer.transportPendingUserInput(DataContainer.java:474)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.transport(ClientComponent.java:548)
         at com.sap.tc.webdynpro.clientserver.cal.ClientComponent.transport(ClientComponent.java:552)
         at com.sap.tc.webdynpro.clientserver.cal.ClientApplication.transport(ClientApplication.java:701)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.transportData(WebDynproMainTask.java:717)
         at com.sap.tc.webdynpro.clientserver.task.WebDynproMainTask.execute(WebDynproMainTask.java:649)
         at com.sap.tc.webdynpro.clientserver.cal.AbstractClient.executeTasks(AbstractClient.java:59)
         at com.sap.tc.webdynpro.clientserver.cal.ClientManager.doProcessing(ClientManager.java:251)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doWebDynproProcessing(DispatcherServlet.java:154)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doContent(DispatcherServlet.java:116)
         at com.sap.tc.webdynpro.serverimpl.defaultimpl.DispatcherServlet.doPost(DispatcherServlet.java:55)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.runServlet(HttpHandlerImpl.java:390)
         at com.sap.engine.services.servlets_jsp.server.HttpHandlerImpl.handleRequest(HttpHandlerImpl.java:264)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:347)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.startServlet(RequestAnalizer.java:325)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.invokeWebContainer(RequestAnalizer.java:887)
         at com.sap.engine.services.httpserver.server.RequestAnalizer.handle(RequestAnalizer.java:241)
         at com.sap.engine.services.httpserver.server.Client.handle(Client.java:92)
         at com.sap.engine.services.httpserver.server.Processor.request(Processor.java:148)
         at com.sap.engine.core.service630.context.cluster.session.ApplicationSessionMessageListener.process(ApplicationSessionMessageListener.java:33)
         at com.sap.engine.core.cluster.impl6.session.MessageRunner.run(MessageRunner.java:41)
         at com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
         at java.security.AccessController.doPrivileged(Native Method)
         at com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:100)
         at com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:170)
    Caused by: com.sap.engine.services.ejb.exceptions.BaseEJBException: SQLException while the data is being flushed. The persistent object is pl.com.bcc.hai.SpecificationBean0Persistent.
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:101)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flushAll(TransactionContext.java:429)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.flush(TransactionContext.java:378)
         at com.sap.engine.services.ejb.entity.pm.TransactionContext.beforeCompletion(TransactionContext.java:506)
         at com.sap.engine.services.ejb.entity.SynchronizationList.beforeCompletion(SynchronizationList.java:136)
         at com.sap.engine.services.ts.jta.impl.TransactionImpl.commit(TransactionImpl.java:220)
         ... 36 more
    Caused by: com.sap.sql.log.OpenSQLException: Cannot assign double value 4.9E-324 to host variable 3 because it is not in the allowed range of +/- to +/-.
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:85)
         at com.sap.sql.log.Syslog.createAndLogOpenSQLException(Syslog.java:124)
         at com.sap.sql.jdbc.common.CommonPreparedStatement.setDouble(CommonPreparedStatement.java:534)
         at com.sap.engine.services.dbpool.wrappers.PreparedStatementWrapper.setDouble(PreparedStatementWrapper.java:281)
         at pl.com.bcc.hai.SpecificationBean0Persistent.ejb_iUpdate(SpecificationBean0Persistent.java:558)
         at com.sap.engine.services.ejb.entity.pm.UpdatablePersistent.ejbFlush(UpdatablePersistent.java:80)
         ... 41 more

    Hi,
       Thank you for your replay. I didn't touch DB directly, I defined db structure through NetWeaver Dictionary perspective and table that i'm interested in is defined like the one on this screen: http://zduniak.com/tmp/sap_dictionary_double.png
    So I'm looking for generic solution (SAP OpenSQL), not specific to any particular DB vendor.
    Maybe there is somewhere on help.sap.com (i couldn't find unfortunately) information what is the allowed range of values for type 'double' in database according to OpenSQL spec ?
    Thank,
      Marcin Zduniak

  • BO Webi report hierarchy with measure values showing more(almost double value) compare to BW Bex report

    Hi,
    In our BO Webi report hierarchy with measure values showing more(almost double value) compare to BW Bex report. Can any one please help on this.
    Is it BW problem or BO problem?
    I checked in some other threads but it's not given solution.
    Thanks,
    Manjunatha

    Hi,
    Is it BW problem or BO problem? : BO
    is it causing problem with hierarchly data only ?  without hierarchies data is matching or not?
    Post same in SAP BusinessObjects Web Intelligence  .
    Thanks.

  • Double value truncated to two decimal places without rounding the value.

    I want to truncate double value to two decimal places without doing the rounding of the value.
    Is there any method which can directly do the truncation.

    There's many ways to achieve this such as using
    BigDecimal's setScale method or type-casting. This is
    the way I like to do it:double d = -5.239;
    d = d > 0 ? Math.floor(d * 100) / 100.0 : Math.ceil(d
    * 100) / 100.0;
    Your division by 100 may cause an rounding error, because there are numbers which no finite binary representation. That's splitting hairs! I know ;-)

  • Unable to display double values in Excel sheet using JExcel API

    Hi
    I am writing code to generate report in the form of Excel Sheet using JExcel API.
    Everything is going fine but whenever I want to put some double values in a cell it is only showing 2 decimal places. My problem is "I want to show upto five decimal places".
    Any kind of reply might help me lot.
    Thank U.

    If you enable the submit zero option, it still happens? This is a new feature on the display tabl
    #NumericZero Enhancements
    To display a numeric zero in place of an error message, you can enter #NumericZero in any of the three Replacement text fields. When you use the #NumericZero option:
    · Excel formatting for the cell is retained.
    · All calculations with dependency on the cell will compute correctly and will take the value of this cell as zero.
    · This numeric zero is for display only. When you submit, the zero value is NOT submitted back to the data source.
    You cannot set display strings for cells that contain an invalid member or dimension name (metadata error). Metadata errors produce standard descriptive error messages.
    Errors are prioritized in the following order from highest to lowest. The error message for a higher-priority error takes precedence over that for a lower-priority error.
    1. (Highest) Metadata errors
    2. #No access
    3. #Invalid/Meaningless
    4. #No data\Missing

  • Getting Double values in Purchasing cube

    hi experts,
    I m getting double values for 0po_items and ocontr_item in purchasing data cube 0pur_c01.
    i have also applied the test rule in routine ,that values are fine.
    but in cube values are getting double.
    please help..........

    Hi,
    It seems like you are loading data into cube using 2 DataSource  and there is no (consolidated) dso in between.
    If the KF say (qty) you are mapping from both the datasource to the cube, it is going to be doubled in report as 2 records will be found in cube.
    I suggest try to load a single valid record (PO and lien item) one by one into the cube and do check the values in cube for each process. You will get good idea how cube behave while loading data from diff. sources.
    Also try to bring in the one dso where you consolidate the data as per report requirement and then move that data into Cube, will give you required output.
    Thank-You.
    Vinod

  • Need some help in Rounding a double value to a whole number

    Hey Peeps,
    Need some help here, I got a method that returns a value in double after a series of calculation.
    I need to know how can I round the double value, so for example,
    1. if the value is 62222.22222222, it rounds to 62222 and
    2. if the value is 15555.555555, it rounds to 15556
    How can i do this
    Zub

    Hi Keerthi- Try this...
    1. if the value is 62222.22222222, it rounds to 62222 and
    double d = 62222.22222222;long l = (int)Math.round(d * 100); // truncatesd = l / 100.0;
    double d = 62222.22222222;
    System.out.println(d);
    long l = (int)Math.round(d * 100);
    // truncatesSystem.out.println(l);
    d = l / 100.0;System.out.println(d);
    for (int i = 0; i < 1000; i++)
    {    d -= 0.1;}
    for (int i = 0; i < 1000; i++)
    {    d += 0.1;}System.out.println(d);
    regards- Julie Bunavicz
    Output:
    62222.22222222
    62222
    62222.22
    62222.22000000000001

  • How do i convert a float value to a double value?

    How do i convert a float value to a double value? HELP PLEASE!! im very stuck!! i gota float data type and i need to convert it to a double data type in order to use it in another operation.....
    thank u so much!

    safe dint realise ppl were so arrogant. thanks for the reply but less of the sarcasm!

  • How can I format the double value?

    Hi,
    I am trying to format the double variable as like,
    double var = 1234.56789
    but i want that variable as like var = 1234.56
    How can i do that in java?
    Please help me.
    From
    Parshuram Walunjkar

    Try something like the following, assume the variable 'd' underneath is your double value that you want to format.
    double d = 4.45678;
    NumberFormat nf = NumberFormat.getNumberInstance();
    nf.setMaximumFractionDigits(5);
    nf.setMinimumFractionDigits(5);
    String number = nf.format(d);
    Then use the string "number" for printing out.

  • How to convert from scientific notations to double value ?

    Hi all,
    i need to convert a string 2E-23 to corresponding double values so that i can compare it one more existing double value. Is there any API present for this ?
    Thanks and regards,
    rosamama.

    Note: This thread was originally posted in the Swing forum, but moved to this forum for closer topic alignment.

  • JSlider using double values instead of INT

    I need to create a slider that uses double values instead of ints...
    the default constructor is JSlider temp = new JSlider(JSlider.HORIZONTAL, int, int, int)....but i need to use
    JSlider temp = new JSlider(JSlider.HORIZONTAL, double,double,double)
    I want my slider to go from like 1.0 to 10.0 ....any ideas?
    thanks

    me has ritten a sample code fur ya... mite help...
    sorrie... not commented properly...
    import java.awt.event.*;
    import java.util.Vector;
    import javax.swing.event.*;
    import java.awt.*;
    import javax.swing.*;
    public class Test extends JPanel {
         //Variable Declarations...
         JPanel valuesPanel;
         public JSlider slider;
         public JTextField midText;
         public JTextField lowText;
         public JTextField highText;
         int precision=1000;//to convert to double...(100-> 2decimal places, 1000->3decimal places.......)
         double lowLimit = 0;
         double midLimit = 5;
         double highLimit = 10;
         public Test() {
              initialize();
              addListeners();
              initComponents();
              addComponents();
         public void initialize() {
              valuesPanel = new JPanel();
              highText = new JTextField();
              midText = new JTextField();
              lowText = new JTextField();
              slider = new JSlider();
         public void addListeners() {
              addTextListenerTo( highText );
              addTextListenerTo( midText );
              addTextListenerTo( lowText );
              // if the slider is moved, the value of the mid will be updated in the testbox.
              // Sliders work on integers and not on double. so the limits are divided by precision to get a double number.
              slider.addChangeListener(
                   new ChangeListener() {
                        public void stateChanged( ChangeEvent e ) {
                             double n = ( double ) ( ( JSlider ) e.getSource() ).getValue();
                             midLimit = n / precision;
                             midText.setText( Double.toString( midLimit ) );
         * Sets different attributes and properties of the components
         public void initComponents() {
              highText.setText( Double.toString( highLimit ) );
              midText.setText( Double.toString( midLimit ) );
              lowText.setText( Double.toString( lowLimit ) );
              slider.setPaintTrack( true );
              slider.setPaintTicks( true );
              slider.setMinimum( ( int ) ( lowLimit * precision ) );
              slider.setValue( ( int ) ( lowLimit * precision ) );
              slider.setMaximum( ( int ) ( highLimit * precision ) );
         * Add all the components to the container (Panel).
         public void addComponents() {
              setLayout( new BorderLayout() );
              valuesPanel.setLayout( new GridLayout( 3, 3, 5, 5 ) );
              valuesPanel.add( new JLabel("Low") );          
              valuesPanel.add( highText );
              valuesPanel.add( new JLabel("Mid") );
              valuesPanel.add( midText );
              valuesPanel.add( new JLabel("High") );
              valuesPanel.add( lowText );
              add( valuesPanel, BorderLayout.CENTER);
              add( slider, BorderLayout.SOUTH);
         * Adds Focus and Action Listeners to the TextFields
         public void addTextListenerTo( JTextField textField ) {
              textField.addFocusListener(
                   new FocusAdapter() {
                        public void focusLost( FocusEvent evt ) {
                             updateLimits( ( JTextField ) evt.getSource() );
                        public void focusGained( FocusEvent evt ) {
                             String tempOldString = ( ( JTextField ) evt.getSource() ).getText();
              textField.addActionListener(
                   new ActionListener() {
                        public void actionPerformed( ActionEvent evt ) {
                             updateLimits( ( JTextField ) evt.getSource() );
         * This function is called when any action is performed on the text. It checks
         * if the value is valid and if not it displays a message. Also it updates the
         * slider value.
         *@param textField
         public void updateLimits( JTextField textField ) {
              double tempN = 0;
              try {
                   tempN = Double.parseDouble( textField.getText() );
                   if ( textField.equals( lowText ) ) {
                        lowLimit = tempN;
                        slider.setMinimum( ( int ) ( lowLimit * precision ) );
                   else if ( textField.equals( highText ) ) {
                        highLimit = tempN;
                        slider.setMaximum( ( int ) ( highLimit * precision ) );
                   else if ( textField.equals( midText ) ) {
                        midLimit = tempN;
                        slider.setValue( ( int ) ( midLimit * precision ) );
              } catch ( Exception ex ) {
                   JOptionPane.showMessageDialog( this, "Not a Number", "Error !!!", JOptionPane.WARNING_MESSAGE );
                   textField.setText( "0" );
         public static void main(String args[]) {
         JFrame f=new JFrame("test Frame");
         f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         f.getContentPane().add(new Test());
         f.pack();
         f.setVisible(true);

  • Cash Flow Report (FSI3/FSI5) pulling double value

    Dear SAP Experts
    I am creating a Cash Flow Statement via FSI3 /FSI5. While selecting key figure "Total Credit Postings" system is pulling the double values for the assigned GL. Please see below;
    Please see the output.
    GL total credit value is 269610.68 where as report is showing value 539221, which is double the value.
    Any suggestions to correct the error??
    Regards
    Syed Zia Abbas

    Hi Melia
    For your calculation, you can cross check your logic with actual values form table and  see why it is not matching in case of INCORRECT amount.
    Cash Flow is genuinely generated per Fiscal year and that will show the comparison of Reporting year (For Ex Current Year) with comparison year (For Ex Last Year).
    As a correct solution, you can give selection parameter as below;
    Reporting Year
    Reporting Pd From
    Reporting Pd To
    Comparison Year
    Comparison Pd From
    Comparison Pd To.
    That is the way I have created CFS. Let me know if you need more info.
    Regards
    Syed Zia Abbas

  • SQ01 double value

    Hi,
    In my sq01 Query i am using LDB SDF ( FI/CO) .
    It running Successfully.
    only one Problem is that  it showing Double Value Why ?
    How to Solve this ?
    Thanks

    What is showing double value.
    It may be because the output may be at the line level.

  • Converting String  into a Double value

    Hi
    iam really stuck can anyone please help that what i should do
    to convert a String variable into a double value
    iam using CLDC1.1 and MIDP2.0
    please tell me how its done
    Thank in advance

    hi,
    thanx alot it really worked now i want to convert the answer of the double variable back to string can you please tell me how to do it thanx alot

Maybe you are looking for